Connect to a SQL Database

by AntoniMG » Wed, 08 Jul 2009 01:02:43 GMT

Sponsored Links

Im triying to connect to a SQL Database with Android, this is my code:

package com.example.conversor;
import java.sql.*;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


try {
} catch (Exception e) {

try {
DBConnSQL = DriverManager.getConnection("jdbc:sqlserver://zeus:
} catch (Exception e)

And this is what i get:

07-07 11:16:27.450: ERROR/jdwp(1597): Failed sending reply to
debugger: Broken pipe
07-07 11:16:29.832: ERROR/dalvikvm(1605): Could not find class
'javax.sql.XAConnection', referenced from method
07-07 11:16:29.931: ERROR/AndroidRuntime(1605): Uncaught handler:
thread main exiting due to uncaught exception
07-07 11:16:29.983: ERROR/AndroidRuntime(1605): java.lang.VerifyError:
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at Source)
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at$1800(
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at$H.handleMessage(
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
java.lang.reflect.Method.invokeNative(Native Method)
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at$
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
07-07 11:16:29.983: ERROR/AndroidRuntime(1605):     at
dalvik.system.NativeStart.main(Native Method)

SQL Server is correctly installaed and configured, and receiving
Querys from other app.



Connect to a SQL Database

by Charlie Collins » Wed, 08 Jul 2009 04:06:08 GMT

 n general you don't want to do that - connect directly to your SQL
server from Android. If your Android device is on the same subnet,
and you configure host resolution and port access, you *might* be able
to do that, I have never really thought to try, but it's certainly not
the normal path.

Normally, you will want a server side API, like REST or such, that you
can call from Android using HTTP or something. That way your device
can connect to your server side API and it doesn't need to know
anything about it being a SQLServer (the abstraction is at a different
level), and it will work regardless of whether or not you are on the
same subnet. Have a look at a REST implementation for your favorite
server side language (Jersey for Java, whatever for .net, etc) and
create a simple server side for your Android app to connect to, and
try that.

On Jul 7, 7:18am, AntoniMG <> wrote:

Sponsored Links

Other Threads

1. developing input hardware device for Android

I'm a total newbie to developing for Android and I could be in over my
head for this but I'm a fast learner with programming languages so I
thought I'd give it a shot.   As for the hardware part, that'll be
more difficult.

I'm a big fan of the NESOID app for Android and every time I play I
keep thinking of how it would be great to develop a controller for the
android so you get better gameplay than using the keyboard.  (plus I
feel like I'm going to wear out those specific keys on the keyboard
that I keep repeatedly using to play)

So my question is,  how would I go about this?  What kind of hardware
should i get?  I assume this controller would plug into the USB.  In
my mind it seems simple enough.  Each button of the controller would
correspond the pressing a letter on the keyboard.  So this controller
would work on multiple games that use the keyboard,  like Doom for
Android, Kidd GBC, Alien {*filter*} Bath, etc..

Right now I have this as the common control settings.
Up = 1,  Down = A, Left = Q , Right = W
B = O, A = P, Select = Del, Start = Return

So basically the input into my G1 from the controller would mimic
pressing these letters.  Maybe with an App you would also able to
changes these settings.

since I don't know if I can upload pictures to these forums, here's a
crappy ascii drawing of what the controller would look like.

               |                                     |
               |                                     |
-----------               G1                    --------------
|               |                                    |               |
|    U        |                                    |   X   Y     |
|  L   R     -------------------------------   B   A      |     --->
slides open this way so the USB can be plugged in.
|    D                    select  start                       |



2. filled database doesn't appear in listview


I have done several tutorials and tried to read everything carefully,
but I still can't fix my problem.
I have a simple database that works. I can read from the database
successfully by printing some rows to the catlog:

Cursor NumbersCursor = db.getNumbers();

Log.d("ColCount ",new Integer(NumbersCursor.getColumnCount()).toString
Log.d("Columns  ", arrayToString(NumbersCursor.getColumnNames(),","));
while(NumbersCursor.moveToNext()) {
        Log.d("CursorPosition ",new Integer(NumbersCursor.getPosition

Now since this works I want to show the data also on the device:

String[] from = new String[]{"title"};
int[] to = new int[]{};

ListAdapter adapter =
                    new SimpleCursorAdapter(


But I always receive the "no data" screen on the device.
Does anyone know what I did wrong ?


3. Post Only Twitter client -- POT alpha release.

4. TextView Link to Android Settings

5. Anyone know how to build the gsptest?

6. How to write .jpg/.png file to gallery in Android

7. What should I do if I change the framework code in Android?