是給錯誤/安卓無法連接到MySQL在JAVA
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
錯誤: 無法創建連接到數據庫服務器。
10-28 18:25:05.621: D/AbsListView(20635): Get MotionRecognitionManager
10-28 18:25:05.626: E/MYSQL(20635): Erro: Could not create connection to database server.
10-28 18:25:05.626: E/MYSQL(20635): Erro: java.lang.NullPointerException
10-28 18:25:05.626: W/System.err(20635): Got an exception!
10-28 18:25:05.626: W/System.err(20635): Could not create connection to database server.
10-28 18:25:05.636: E/MYSQL(20635): Erro: java.lang.NullPointerException
MAIN:
//Conectar no Banco
conn = new ConnectMysql();
try {
conn.getConexato();
} catch (Exception e) {
Log.e("MYSQL", "Erro: " + e.getMessage());
}
}
ConnectMysql:
public Connection getConexato() throws ClassNotFoundException,
SQLException, java.sql.SQLException, InstantiationException,
IllegalAccessException {
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = (Connection) DriverManager.getConnection("jdbc:mysql://mysql.hostinger.com.br:3306/u917553846_123","u917553846_admin","teste123");
return conn;
}
將堆棧跟蹤添加到您的錯誤日誌中:'Log.e(e);'這會給你更多關於拋出'NullPointerException'的信息 – Niro
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:可能不創建與數據庫服務器的連接。 – user2774657