[英]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.