当我尝试使用java / android
连接到mysql时出错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
主要
//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;
}
答案 0 :(得分:0)
请检查Android应用是否具有访问互联网服务的正确权限。
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
答案 1 :(得分:0)
mysql.hostinger.com.br
是不存在的域名。你确定db的地址吗?