안드로이드 앱을 mssql 데이터베이스에 연결하려고합니다. 하지만 연결을 시도 할 때 예외가 생겼습니다. 디버그 모드에서 체크하고 예외 캐치 여기에 내 코드가 있습니다.안드로이드 앱에 mssql 연결
protected void onStart() {
try
{
// Load the SQLServerDriver class, build the
// connection string, and get a connection
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://xxx\\xxxxx:1433;" +
"database=xxxx;" +
"user=xxxx;" +
"password=*****";
Connection con = DriverManager.getConnection(connectionUrl);
System.out.println("Connected.");
// Create and execute an SQL statement that returns some data.
String SQL = "SELECT COUNT(*) FROM xxxxxx";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(SQL);
TextView tv=(TextView) findViewById(R.id.textView1);
tv.setText((CharSequence) rs);
// Iterate through the data in the result set and display it.
while (rs.next())
{
System.out.println(rs.getString(1) + " " + rs.getString(2));
}
} catch (Exception e) {
e.printStackTrace();
}
super.onStart();
}