Home > Mobile >  Second Android JDBC access connection is empty
Second Android JDBC access connection is empty

Time:11-05

The first connection can query results come out, the second call getConnection () error directly connection is null, the connection is null is DriverManager getConnection ()
After the first connection query also found empty closed, the second call out doesn't come as a result,
And the same code, copy and paste the same JDBC in Java is normal, not a in Android,
The debug to DriverManager. The getConnection (" JDBC: mysql://"+ IP +" : "+ port +"/" + dbName, dataBaseUserName, dataBasePassWord);
Into the core of the JDBC code, look not to understand,,,
Step over the words will be catch SQLException, e. cannot connect to the database,
 
Private Connection getConnection () {
The Connection Connection=null;
Try {
Class.forName("com.mysql.jdbc.Driver");
The connection=DriverManager
GetConnection (" JDBC: mysql://"+ IP +" : "+ port +"/" + dbName,
DataBaseUserName dataBasePassWord);
Return the connection;
} the catch (a ClassNotFoundException e) {
e.printStackTrace();
} the catch (SQLException e) {
e.printStackTrace();
}
return null;
}

  • Related