0
這是我的連接類連接到服務器無法訪問在蔚藍的SQL表從機器人工作室
public class ConnectionClass {
@SuppressLint("NewApi")
public static Connection CONN() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection conn = null;
String ConnURL = null;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:jtds:sqlserver://jazzitup.database.windows.net:1433;database=jazzitup.db;user=xxxxxxxx;password=xxxxxxxx;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30");
System.out.println("AZURE:"+conn);
} catch (SQLException se) {
Log.e("ERRO", se.getMessage());
} catch (ClassNotFoundException e) {
Log.e("ERRO", e.getMessage());
} catch (Exception e) {
Log.e("ERRO", e.getMessage());
}
return conn;
}
}
這個我叫CONN方法後,連接被越來越建立。 但是當我嘗試執行插入opertion:
Connection con = ConnectionClass.CONN();
String query = "insert into user_table values ('" + profile.getId() + "','" + profile.getName() + "','" + profile.getProfilePictureUri(200,200).toString() + "')";
PreparedStatement preparedStatement = con.prepareStatement(query);
preparedStatement.executeUpdate();
我得到SQLEXCEPTION「USER_TABLE」是無效的對象。這是爲什麼發生?
你有任何更新? –