Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I try to connect from eclipse emulator android to an sql server using this code:

String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
String connString = "jdbc:jtds:sqlserver://83.212.240.15:1521/hua;encrypt=fasle;user=xxxxxx;password=xxx;instance=SQLEXPRESS;";
String username = "xxxxx";
String password = "xxxxx";
conn = DriverManager.getConnection(connString,username,password);
Statement stmt = conn.createStatement();
ResultSet reset = stmt.executeQuery("insert into picture values('hi');");
conn.close();

but i have the following error

Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cebcd0 that was originally bound here
android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d64ec0 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:969)

I have put the permission for internet and i also i have put the jtds-1.3.0.jar in lib folder.Any ideas?

Thanks in adnvanced

share|improve this question
 
Please copy and paste the logcat. The image is not readable on my end. –  Code-Guru Jun 16 '13 at 17:59
 
Can you zoom it? –  Tony Jun 16 '13 at 18:03
 
Nope, I can't.. –  Code-Guru Jun 16 '13 at 18:06
 
i removed the picture –  Tony Jun 16 '13 at 18:13
 
possible duplicate of Various android logcat errors –  Code-Guru Jun 16 '13 at 18:18
show 2 more comments

2 Answers

You get that error because you are using stmt.executeQuery.

stmt.executeQuery expects something in return (that means a result from a SELECT), but you are inserting data, not querying, so you should use stmt.executeUpdate instead

share|improve this answer
add comment

Use SQLite database for android Tutorial and About SQLite database

share|improve this answer
1  
This is only for local database in android. –  Tony Jun 16 '13 at 18:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.