Im currently trying to establish a connection from my Android app to a MySQL server running on my raspberry pi.
I added the library to android studio correctly by adding it's into the dependencys in the module menu.
I implemented the JDBC-method like this into my program.
public void readDatabase(String query)throws Exception{
try {
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://192.168.0.101/mydb","user","mypassword");
statement = connection.createStatement();
resultSet = statement.executeQuery(query);
System.out.println(resultSet);
}catch (ClassNotFoundException e){
e.printStackTrace();
}finally {
close();
}
}
private void close(){
try {
if (resultSet != null){
resultSet.close();
}
if (statement != null){
statement.close();
}
if ( connection != null){
connection.close();
}
}catch (Exception e){
}
}
Every time I fire up the program I get an class not found error.
It says :
W/System: ClassLoader referenced unknown path: system/framework/mediatek-cta.jar
I/System.out: e:java.lang.ClassNotFoundException: com.mediatek.cta.CtaHttp
I tried to search in different ways for the problem but I can not figure out where the problem is.
I don't even know what the cta class is. Maybe someone can help me out here.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…