I have a MYSQL table hosted in amazon AWS called LoginScreen. How to access it with Android Studio. In a normal java code i am using a jdbc-mysql connector and i connect to it. So i tried to do the same but i am unable to connect with it.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
}catch(Exception e){
System.err.println("Cannot create connection");
}
Connection connection=null;
TextView sample;
try{
connection = DriverManager.getConnection("jdbc:mysql://samplelink/database","root","password");
Statement statement = connection.createStatement();
sample = (TextView) findViewById(R.id.sample);
ResultSet resultset = statement.executeQuery("select * from Loginscreen");
while(resultset.next()){
System.out.println("Solution"+resultset.getString(1));
txtLat.append(resultset.getString(1));
}
}catch(Exception e){
sample = (TextView) findViewById(R.id.sample);
System.err.println("Error");
sample.append(e.toString());
}
}
I have added the following to android manifest.
<uses-permission android:name="android.permission.INTERNET" />
I am getting the following error
java.lang.classNotFoundException:com.mysql.jdbc.Driver
How to use jdbc driver in Android studio like we use in Netbeans. If i import the connector i get a gradle error while running the code. Can someone explain me how to do this in a step by step fashion?