So, i've already searched in millions of topics here in stack overflow and no one was able to help me. I have an android project in eclipse and i just want to connect to my mysql database that is being hosted locally but i keep receiving an error (i've treated the exception to display a toast message and all i get in this toast is "com.mysql.jdbc.Driver" which is the path of the drive, i assume). I've already pasted the jdbc connector in the "libs" folder i've created inside the project and i already added this jar file to the build path and now i have the mysql connector in the Referenced Libraries folder and in the libs folder. I also put the connector in the directory "c:\program files\java\jdk\jre\lib\ext". My code looks like this:
import java.sql.*;
public class MainActivity extends Activity{
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost/MyDB";
String user = "root";
String pass = "";
Connection conn;
private void LoadDB(){
try{
Class.forName(driver);
conn = DriverManager.getConnection(url,user,pass);
}
catch(Exception e){
Toast.makeText(getApplicationContext(),e.getMessage(),5).show();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LoadDB();
}
}