4

有谁知道我可以做些什么来使 JDBC 连接在 Android 4.0 上工作。它在 Android 1.6-2.3 上运行良好。我使用 Dave Cramer 的构建: http ://groups.google.com/group/pgandroid/browse_thread/thread/d8b400f039f66d5f/f77b2e2a99370a36?lnk=raot#f77b2e2a99370a36

Logcat 说:

06-10 17:35:51.043: E/AndroidRuntime(798): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.belonogov.connectjdbc/com.belonogov.connectjdbc.ConnectJDBCActivity}: java.lang.NullPointerException
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.os.Handler.dispatchMessage(Handler.java:99)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.os.Looper.loop(Looper.java:137)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread.main(ActivityThread.java:4424)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at java.lang.reflect.Method.invokeNative(Native Method)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at java.lang.reflect.Method.invoke(Method.java:511)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at dalvik.system.NativeStart.main(Native Method)
06-10 17:35:51.043: E/AndroidRuntime(798): Caused by: java.lang.NullPointerException
06-10 17:35:51.043: E/AndroidRuntime(798):  
at com.belonogov.connectjdbc.ConnectJDBCActivity$CustomDrawableView.<init>(ConnectJDBCActivity.java:81)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at com.belonogov.connectjdbc.ConnectJDBCActivity.onCreate(ConnectJDBCActivity.java:27)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.Activity.performCreate(Activity.java:4465)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-10 17:35:51.043: E/AndroidRuntime(798):  
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-10 17:35:51.043: E/AndroidRuntime(798):  
... 11 more

它只是一个连接到数据库的简单应用程序。

4

2 回答 2

2

如果可能,请考虑在您的 android 设备上摆脱直接 JDBC。它在往返等方面效率低下,并且在面对不可靠的连接时也不可靠。

请参阅如何在 android 中安全(间接)查询 postgresql 数据库?.

于 2012-06-11T02:23:05.250 回答
0

您很可能会在这里找到答案:

06-10 17:35:51.043: E/AndroidRuntime(798): Caused by: java.lang.NullPointerException
06-10 17:35:51.043: E/AndroidRuntime(798):      at com.belonogov.connectjdbc.ConnectJDBCActivity$CustomDrawableView.<init>(ConnectJDBCActivity.java:81)
06-10 17:35:51.043: E/AndroidRuntime(798):      at com.belonogov.connectjdbc.ConnectJDBCActivity.onCreate(ConnectJDBCActivity.java:27)

这意味着:查找类ConnectJDBCActivity.java,第 81 行并查看引用可能是什么null

于 2012-06-10T20:41:35.627 回答