0
我想12小時現在從我的數據庫中選擇數據,但我不能。sql連接錯誤 - 阻止我從'SELECT'數據從mysql
INSERT正常工作。只是選擇不工作。
當我運行connect()函數我我得到很多的誤區:
public void connect() {
String dbUrl = "jdbc:mysql://*****.heliohost.org:3306/*****";
try
{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(dbUrl,"*****","****");
return;//the debugger never succeed to reach this line
} catch (Exception e) {
e.printStackTrace();
}
}
的錯誤,我從上面得到connect()函數:
12-23 16:22:54.460: W/dalvikvm(7473): VFY: unable to find class referenced in signature (Ljavax/naming/Reference;)
12-23 16:22:54.470: I/dalvikvm(7473): Could not find method javax.naming.Reference.get, referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.initializeFrom
12-23 16:22:54.470: W/dalvikvm(7473): VFY: unable to resolve virtual method 14440: Ljavax/naming/Reference;.get (Ljava/lang/String;)Ljavax/naming/RefAddr;
12-23 16:22:54.470: D/dalvikvm(7473): VFY: replacing opcode 0x6e at 0x0004
12-23 16:22:54.491: W/dalvikvm(7473): VFY: unable to find class referenced in signature (Ljavax/naming/Reference;)
12-23 16:22:54.491: E/dalvikvm(7473): Could not find class 'javax.naming.StringRefAddr', referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.storeTo
12-23 16:22:54.491: W/dalvikvm(7473): VFY: unable to resolve new-instance 1365 (Ljavax/naming/StringRefAddr;) in Lcom/mysql/jdbc/ConnectionPropertiesImpl$ConnectionProperty;
12-23 16:22:54.491: D/dalvikvm(7473): VFY: replacing opcode 0x22 at 0x0006
下一個功能下降「String tem = result.getString(」name「)」:
public List<String> selectCategories()
{
List<String> listCS = new ArrayList<String>();
try
{
Statement statement = connection.createStatement();
statement.execute("select name from categories");
ResultSet result=statement.getResultSet();
if(result!=null)
{
while(result.next());
{
String tem = result.getString("name");
listCS.add(tem);
}//end of while
}//end of if
}//end of try
catch(java.sql.SQLException e)
{
e.printStackTrace();
}
return listCS;
}
我做了'GRANT ALL'給我的用戶,我正在連接到數據庫。我會添加接近資源。但這並不能解決我的錯誤。 – CmTiger
這些堆棧跟蹤不是您從DriverManager連接看到的。你可以在沒有Android的情況下單獨測試該類嗎?我建議你這樣做。 – duffymo
我做了你所說的 - 我創造了新的項目,並完美地工作。你知道我怎麼解決這個問題? /: – CmTiger