繁体   English   中英

Android SQL数据库连接

[英]Android sql database connection

我尝试使用以下代码从eclipse模拟器android连接到sql服务器:

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();

但我有以下错误

服务com.android.exchange.ExchangeService泄漏了最初绑定在此处的ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cebcd0
android.app.ServiceConnectionLeaked:服务com.android.exchange.ExchangeService泄漏了最初绑定在此处的ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d64ec0
在android.app.LoadedApk $ ServiceDispatcher。(LoadedApk.java:969)

我已经允许访问互联网,我也已经将jtds-1.3.0.jar放在lib文件夹中。有什么想法吗?

感谢高级

因为使用stmt.executeQuery,所以收到该错误。

stmt.executeQuery期望返回某些信息(这表示SELECT的结果),但是您正在插入数据而不是查询,因此应改用stmt.executeUpdate

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM