I am trying to connect to a MySQL database via Android Studio. I have written the following class to handle the connection.
public class ConnectionHelper2 {
String uname, pass, ip, port, database;
@SuppressLint("NewApi")
public Connection connectionClass(){
ip = "sci-project.lboro.ac.uk";
database = "codc2";
uname = "codc2";
pass = HIDDEN;
port = "3306";
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection con = null;
try{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String ConnectionURL = "jdbc:jtds:sqlserver://"+ip+":"+port+";databasename="+database+";User="+uname+";password="+pass+";";
con = DriverManager.getConnection(ConnectionURL);
System.out.println("works");
}catch(Exception ex){
Log.e("Errors ", ex.getMessage());
}
return con;
}
This class is then instantiated in my MainActivity file. However, whenever the program gets to the con = DriverManager.getConnection(ConnectionURL); line of code, the program throws the following Exception.
I/O Error: Unknown packet type 0x52
Any idea why this is? I have the 'jtds-1.3.1.jar' file in my library folder and under my gradle dependencies. I am new to android development and am really stuck on why this isn't working.