I found some answers but nothing was useful.
I added mysql-connector-java-5.1.7-bin.jar to referenced libraries and the following method to my main class activity.
private void getServerData(String id, String type) throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException
{
Log.i("Database Connection", " requesting data from server");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://10.0.2.2:3306/db_easy_maintenance", "root", "maintenance");
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery("SELECT Name FROM industrial_object");
String entry;
while(rs.next())
{
entry=rs.getString("Name");
Log.i("Database Connection", "getting " + entry);
}
con.close();
}
I start my app and get an java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at java.lang.Class.classForName.
If I don't use try ...catch... then i get this Exception before compiling.
What's wrong?