0

I have been trying to connect my Android application to a local database that I have created on my PC for testing purpose. I'm using XAMPP to create the database server.

String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
String connString = "jdbc:jtds:sqlserver://" + server + "/" + database + ";user=" + username + ";password=" + password + ";";
con = DriverManager.getConnection(connString);

I'm using the above mentioned code to create the connection.

Every time it throws the following error:

Network error IOException: DB server closed connection.

I've even tried another approach using ConnectionClass to establish a connection, but still got the same result.

I have also configured the firewall to allow inbound requests. Please help!

Dat Nguyen
  • 1,626
  • 22
  • 25
  • XAMPP implies you are using MySQL, jtds is a driver to connect to Microsoft SQL Server and Sybase. You need to use the MySQL Connector/J driver instead if you want to connect to MySQL. – Mark Rotteveel May 27 '17 at 11:57
  • @MarkRotteveel Thank you very much. Am now using the correct driver and it now works. – Shrey Dabhi May 27 '17 at 16:29

0 Answers0