我正在尝试将我的Android应用程序连接到我的天蓝色数据库,以提取一些数据。我关注了互联网上的一些帖子;这给了我下面的代码。现在我知道我必须将jdbc驱动程序添加到我的项目的sql server中;但即使我这样做,我仍然得到上述信息。
有人能给我一些建议吗?
CODE:
try {
// SET CONNECTIONSTRING
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String username = "XXXXXXXXX";
String password = "XXXXXX";
Connection DbConn = DriverManager.getConnection("Connection");
Log.w("Connection","open");
Statement stmt = DbConn.createStatement();
ResultSet reset = stmt.executeQuery(" select Category FROM [dbo].[Feeds]");
Toast toast = Toast.makeText(getApplicationContext(), "Yes", Toast.LENGTH_LONG);
toast.show();
//EditText num = (EditText) findViewById(R.id.displaymessage);
// num.setText(reset.getString(1));
DbConn.close();
} catch (Exception e)
{
Toast toast = Toast.makeText(getApplicationContext(), "Error connection: " + e.getMessage(), Toast.LENGTH_LONG);
toast.show();
//Log.w("Error connection","" + e.getMessage());
}