0

当我尝试使用 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());
    }

}

连接Mysql:

 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;  
}
4

2 回答 2

0

请检查安卓应用是否具有访问互联网服务的正确权限。

<manifest xlmns:android...>
 ...
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
于 2013-10-28T20:45:23.040 回答
0

mysql.hostinger.com.br是不存在的域。您确定您的数据库的地址吗?

于 2013-10-28T22:46:10.307 回答