java Android:使用JDBC?
你能在安卓上使用JDBC驱动程序吗?我已经找到了blobdb,它应该支持安卓,但我似乎无法让它工作,因为我得到了java。sql。SQLException:尝试从查询中获取结果时,权限被拒绝:(
try{
Class.forName("org.vnetcon.blobdb.driver.jdbc.BlobDBDriver").newInstance();
Connection con = DriverManager.getConnection("blobdb|http://localhost:3306/test|username=root|password=password");
Statement stmt = con.createStatement();
String bSQL = "SELECT Name FROM newtable ";
ResultSet rs = stmt.executeQuery(bSQL); // throws exception here
while (rs.next()) {
tmp.popupMessage(getApplicationContext(),rs.getString("Name"));
}
}catch(Exception ex){
tmp.popupMessage(getApplicationContext(),":("+ ex.toString());
}
好了,我修复了最初的错误,现在我在将要查看结果的同一个地方得到了一个空点异常:
try{
Class.forName("org.vnetcon.blobdb.driver.jdbc.BlobDBDriver").newInstance();
Connection con = DriverManager.getConnection("blobdb|http://192.168.0.100:3306/test|username=root|password=houlahan");
String query = "SELECT Name FROM anotheTest";
try
{
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
while (rs.next())
{
String s = rs.getString("Name");
tmp.popupMessage(getApplicationContext(),s);
}
}catch(Exception e){
tmp.popupMessage(getApplicationContext(), e.toString());
}
}catch(Exception ex){
tmp.popupMessage(getApplicationContext(),":("+ ex.toString());
}
我已经尝试了一个原始版本,如果jdbc驱动程序用于桌面应用程序,它会收到结果。我希望有人对我如何让jdbc驱动程序在安卓手机上工作有任何建议吗?:/
提前谢谢
# 1 楼答案
如果查询返回了这个错误,你应该开始思考,这可能与Android或jdbc无关。你应该看看你的数据库设置