App crashing after JDBC DB connection attempt

by josh s » Wed, 30 Jun 2010 02:51:43 GMT


Sponsored Links
 I wrote a function that is supposed to connect to a DB, then close the
connection, for testing purposes, on Android. This is the function:

[code]
public void connectdb(String url, String user, String pass) throws
ClassNotFoundException, SQLException {
         Class.forName("com.mysql.jdbc.Driver");
         Connection conn = (Connection)
DriverManager.getConnection("jdbc:mysql://"+url, user, pass);
         conn.close();
}
[/code]

It is being called in this syntax:

[code]
try {
        connectdb(txt_server_host, txt_username, txt_password);
        popupNotification("Yes!", "Connected successfully!");
} catch (ClassNotFoundException e) {
        popupNotification("ClassNotFoundException", "Error");
} catch (SQLException e) {
        popupNotification("SQLException", "Error");
}
[/code]

Where txt_server_host is a string containing an IP and port
("192.168.1.169:33060" for testing), txt_username and txt_password
contain just plain strings. I know I can successfully connect to the
host (outside my app), since it is also a web server, and Browser can
bring up a page off it. Any ideas? I have the MySQL connector in my
classpath. I just wrote a small function to create a popup with the
attempted URL. It seems correct so far: "jdbc:mysql://
192.168.1.169:3306/".  The app's only permission is Internet.

Stack trace:
Thread [<1> main] (Suspended (exception VerifyError))
        DriverManager.getConnection(String, Properties) line: 196
        DriverManager.getConnection(String) line: 154
        myapp$1.connectdb(String, String, String) line: 66
        myapp$1.onClick(View) line: 53
        Button(View).performClick() line: 2408
        View$PerformClick.run() line: 8816
        ViewRoot(Handler).handleCallback(Message) line: 587
        ViewRoot(Handler).dispatchMessage(Message) line: 92
        Looper.loop() line: 123
        ActivityThread.main(String[]) line: 4627
        Method.invokeNative(Object, Object[], Class, Class[], Class, int,
boolean) line: not available [native method]
        Method.invoke(Object, Object...) line: 521
        ZygoteInit$MethodAndArgsCaller.run() line: 868
        ZygoteInit.main(String[]) line: 626
        NativeStart.main(String[]) line: not available [native method]

--



Other Threads

1. User Question / Keyboard: How to switch between languages on the fly?

When typing text with the iPhone's on-screen-keyboard there is a little
"key" in the lower left that lets me toggle between German and English (in
my case).

I can't seem to find this functionality on the Android keyboard.

I am not interested in another keyboard layout per-se, but very much in the
different dictionaries. Without that it's pretty unusable for me in the
language that I haven't set as my Locale at the moment.

Any ideas? I just checked out Better Keyboard, but I didn't find a one-click
switch option there too.

2. page flipping not supported issue

Hi all,

I am trying to port eclair on beagle board using latest eclair source code.
I have checked out the latest source code and built android root file
system.
I am facing below page flipping problem :

bash-3.2# I/DEBUG   (  829): de{*filter*}d: Jan 13 2010 14:59:23
I/vold    (  828): Android Volume Daemon version 2.0
E/vold    (  828): Unable to chdir to /sys/class/mmc_host/mmc0/slot_name
(Not a directory)
E/vold    (  828): Error bootstrapping card
'/sys/class/mmc_host/mmc0/slot_name' (Not a directory)
I/vold    (  828): New MMC card 'SDM  ' (serial 30109) added @
/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:0002
I/vold    (  828): Disk (blkdev 179:0), 3930112 secs (1919 MB) 2 partitions
I/vold    (  828): New blkdev 179.0 on media SDM  , media path
/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:0002, Dpp2
I/vold    (  828): Partition (blkdev 179:1), 963837 secs (470 MB) type 0xc
I/vold    (  828): New blkdev 179.1 on media SDM  , media path
/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:0002, Dpp1
I/vold    (  828): Partition (blkdev 179:2), 963900 secs (470 MB) type 0x83
I/vold    (  828): New blkdev 179.2 on media SDM  , media path
/devices/platform/mmci-omap-hs.0/mmc_host/mmc0/mmc0:0002, Dpp0
E/vold    (  828): Unable to open '/sys/class/switch' (No such file or
directory)
D/vold    (  828): Bootstrapping complete
D/AndroidRuntime(  831):
D/AndroidRuntime(  831): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
D/AndroidRuntime(  831): CheckJNI is ON
D/AndroidRuntime(  831): --- registering native functions ---
I/        (  832): ServiceManager: 0xad08
W/AudioHardwareInterface(  832): Using stubbed audio hardware. No sound will
be produced.
D/AudioHardwareInterface(  832): setMode(NORMAL)
I/CameraService(  832): CameraService started: pid=832
I/AudioFlinger(  832): AudioFlinger's thread 0xb3a0 ready to run
I/SamplingProfilerIntegration(  831): Profiler is disabled.
I/Zygote  (  831): Preloading classes...
D/dalvikvm(  831): GC freed 791 objects / 50440 bytes in 3ms
D/dalvikvm(  831): GC freed 255 objects / 16392 bytes in 3ms
D/dalvikvm(  831): GC freed 302 objects / 19392 bytes in 4ms
D/dalvikvm(  831): GC freed 222 objects / 14224 bytes in 4ms
D/dalvikvm(  831): GC freed 415 objects / 26376 bytes in 5ms
D/skia    (  831): ------ build_power_table 1.4
D/skia    (  831): ------ build_power_table 0.714286
D/dalvikvm(  831): GC freed 423 objects / 29176 bytes in 5ms
D/dalvikvm(  831): Trying to load lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Added shared lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Trying to load lib /system/lib/libexif.so 0x0
D/dalvikvm(  831): Added shared lib /system/lib/libexif.so 0x0
D/dalvikvm(  831): GC freed 2281 objects / 119200 bytes in 7ms
D/dalvikvm(  831): Trying to load lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Shared lib '/system/lib/libmedia_jni.so' already loaded
in same CL 0x0
D/dalvikvm(  831): Trying to load lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Shared lib '/system/lib/libmedia_jni.so' already loaded
in same CL 0x0
D/dalvikvm(  831): Trying to load lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Shared lib '/system/lib/libmedia_jni.so' already loaded
in same CL 0x0
D/dalvikvm(  831): Trying to load lib /system/lib/libmedia_jni.so 0x0
D/dalvikvm(  831): Shared lib '/system/lib/libmedia_jni.so' already loaded
in same CL 0x0
D/dalvikvm(  831): GC freed 3790 objects / 197008 bytes in 13ms
D/dalvikvm(  831): GC freed 463 objects / 26368 bytes in 12ms
D/dalvikvm(  831): GC freed 292 objects / 16976 bytes in 13ms
D/dalvikvm(  831): GC freed 204 objects / 11496 bytes in 14ms
D/dalvikvm(  831): GC freed 178 objects / 9536 bytes in 15ms
D/dalvikvm(  831): Trying to load lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm(  831): Added shared lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm(  831): Trying to load lib /system/lib/libsrec_jni.so 0x0
D/dalvikvm(  831): Shared lib '/system/lib/libsrec_jni.so' already loaded in
same CL 0x0
D/dalvikvm(  831): GC freed 294 objects / 34656 bytes in 15ms
D/dalvikvm(  831): GC freed 123 objects / 24528 bytes in 22ms
D/dalvikvm(  831): GC freed 337 objects / 38424 bytes in 23ms
D/dalvikvm(  831): GC freed 418 objects / 25856 bytes in 23ms
D/dalvikvm(  831): Trying to load lib /system/lib/libwebcore.so 0x0
D/dalvikvm(  831): Added shared lib /system/lib/libwebcore.so 0x0
D/dalvikvm(  831): GC freed 432 objects / 25120 bytes in 24ms
D/dalvikvm(  831): GC freed 489 objects / 30712 bytes in 24ms
D/dalvikvm(  831): GC freed 349 objects / 28888 bytes in 24ms
D/dalvikvm(  831): GC freed 309 objects / 21792 bytes in 25ms
D/dalvikvm(  831): GC freed 913 objects / 79760 bytes in 29ms
D/dalvikvm(  831): GC freed 664 objects / 35928 bytes in 28ms
D/dalvikvm(  831): GC freed 709 objects / 41240 bytes in 29ms
D/dalvikvm(  831): GC freed 735 objects / 40608 bytes in 29ms
D/dalvikvm(  831): GC freed 14135 objects / 479168 bytes in 35ms
D/dalvikvm(  831): GC freed 10579 objects / 452136 bytes in 36ms
D/dalvikvm(  831): GC freed 10694 objects / 466552 bytes in 39ms
D/dalvikvm(  831): GC freed 7540 objects / 463424 bytes in 39ms
D/dalvikvm(  831): GC freed 8166 objects / 464048 bytes in 40ms
D/dalvikvm(  831): GC freed 8640 objects / 522424 bytes in 40ms
D/dalvikvm(  831): GC freed 6840 objects / 377848 bytes in 40ms
D/dalvikvm(  831): GC freed 847 objects / 51176 bytes in 38ms
D/dalvikvm(  831): GC freed 540 objects / 38720 bytes in 38ms
D/dalvikvm(  831): GC freed 460 objects / 31368 bytes in 38ms
D/dalvikvm(  831): GC freed 426 objects / 29864 bytes in 38ms
I/Zygote  (  831): ...preloaded 1942 classes in 5183ms.
D/dalvikvm(  831): GC freed 117 objects / 14864 bytes in 38ms
I/Zygote  (  831): Preloading resources...
D/dalvikvm(  831): GC freed 5 objects / 224 bytes in 38ms
D/dalvikvm(  831): GC freed 327 objects / 16632 bytes in 39ms
D/dalvikvm(  831): GC freed 269 objects / 12656 bytes in 40ms
I/Zygote  (  831): ...preloaded 48 resources in 427ms.
I/Zygote  (  831): ...preloaded 15 resources in 10ms.
D/dalvikvm(  831): GC freed 114 objects / 8672 bytes in 39ms
D/dalvikvm(  831): GC freed 206 objects / 8112 bytes in 39ms
D/dalvikvm(  831): GC freed 24 objects / 936 bytes in 39ms
I/dalvikvm(  831): Splitting out new zygote heap
I/dalvikvm(  831): System server process 841 has been created
I/Zygote  (  831): Accepting command socket connections
D/dalvikvm(  841): Trying to load lib /system/lib/libandroid_servers.so 0x0
D/dalvikvm(  841): Added shared lib /system/lib/libandroid_servers.so 0x0
E/BatteryService(  841): Could not open /sys/class/power_supply
I/sysproc (  841): Entered system_init()
I/sysproc (  841): ServiceManager: 0x13dc68
I/SurfaceFlinger(  841): SurfaceFlinger is starting
I/SurfaceFlinger(  841): SurfaceFlinger's main thread ready to run.
Initializing graphics H/W...
W/gralloc (  841): page flipping not supported (yres_virtual=768,
requested=1536)
I/gralloc (  841): using (fd=23)
I/gralloc (  841): id           = omapfb
I/gralloc (  841): xres         = 1024 px
I/gralloc (  841): yres         = 768 px
I/gralloc (  841): xres_virtual = 1024 px
I/gralloc (  841): yres_virtual = 768 px
I/gralloc (  841): bpp          = 16
I/gralloc (  841): r            = 11:5
I/gralloc (  841): g            =  5:6
I/gralloc (  841): b            =  0:5
I/gralloc (  841): width        = 163 mm (159.568100 dpi)
I/gralloc (  841): height       = 122 mm (159.895081 dpi)
I/gralloc (  841): refresh rate = 63.61 Hz


Any help will be highly appreciated.

Thanks & Regards,
Deepak

3. Videogame efficency

4. Reading and writing to same file.

5. How to port Android Application in HTC Hero Device.

6. ListView issue

7. Kernel driver for National Instruments USB-6251 device