android JDBC无法正常工作
问题描述:
大家好吧
i有这个代码和java一起使用很多人在android下使用是工作
但是我不能工作
和show消息
没有合适的驱动程序
hi everyone
i have this code working with java and many people used under android is work
but with me not work
and show message
no suitable driver
public void dbConnect(String db_connect_string,
String db_userid,
String db_password)
{
String x=" ";
try {
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (Exception e) {
x +=" 1 ";
}
x+= " befor cpm ";
Connection conn = DriverManager.getConnection(db_connect_string,
db_userid, db_password);
x+= " conne ";
System.out.println("connected");
Statement statement = conn.createStatement();
String queryString = "select * from A_Users";
Cursor rs = (Cursor) statement.executeQuery(queryString);
while (rs.moveToNext()) {
// System.out.println();
x+=rs.getString(2);
}
conn.close();
} catch (SQLException e) {
e.printStackTrace();
x +=e.getMessage() + " mostafa";
}
EditText tex= (EditText) findViewById(R.id.editText1);
tex.setText(x);
}
使用eclipse和上一版本有什么问题
感谢您的帮助
已添加代码块[/编辑]
what is a problem im using eclipse with last version
thanks for any help
Code block added[/Edit]
答
否当驱动程序未加载或连接字符串错误时,会显示合适的驱动程序错误。可能是后者,但肯定也可能是前者,因为你在加载驱动程序时正在吃异常。
The "no suitable driver" error shows up when either the driver isn''t loaded or the connection string is wrong. Could be the latter, but certainly could be the former as well because you are eating the exception when it loads the driver.