Hi everybody,
I'm new on Android, and I'm trying to connect my program to a Mysql Database. The ling between my Android emulator and my server is OK, the ping is good. Moreother, I checked the connexion with a PhP script and everything is ok.
I would like to connect my program directly to the dataBase, using JDBC, et the J-connector. I added it to my project, and the code I use to etablish the connexion is :
The problem is the I have an exception, and I don't know why. The fonction getConnection(DATABASE_URL,"root",""); throw the exception.
Below, the screen shot with variables of the exception :
I'm totally lost, I search for hours and I don't know why I have this exception.
In advance, thank you so much for your help,
Antoine.
I'm new on Android, and I'm trying to connect my program to a Mysql Database. The ling between my Android emulator and my server is OK, the ping is good. Moreother, I checked the connexion with a PhP script and everything is ok.
I would like to connect my program directly to the dataBase, using JDBC, et the J-connector. I added it to my project, and the code I use to etablish the connexion is :
Code:
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String DATABASE_URL = "jdbc:mysql://10.0.2.2/annuaire";
private void initDb() {
try {
Class.forName(DRIVER);
DataBaseConnector.connection = DriverManager.getConnection(DATABASE_URL,"root","pass");
}
catch (SQLException sqlException) {
sqlException.printStackTrace();
}
catch (ClassNotFoundException classNotFound) {
classNotFound.printStackTrace();
}
}
The problem is the I have an exception, and I don't know why. The fonction getConnection(DATABASE_URL,"root",""); throw the exception.
Below, the screen shot with variables of the exception :
I'm totally lost, I search for hours and I don't know why I have this exception.
In advance, thank you so much for your help,
Antoine.