Good day, I am creating an Android program that connects to MS SQL 2012 database on a remote server.. Im currently using Eclipse Juno.. my code works on Eclipse Helius but when I transfer my code to Juno, I encounter problems with connecting to database... I already added drivers such as "mysql-connector-java-5.1.33" and "jtds-1.2.5"
Here is my code:
Connection conn = null;
int a = 0;
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
String connString = "jdbc:jtds:sqlserver://xxx.xxx.xxx.xxx:1433/SAMPLEDB;encrypt=false;user=XX;password=XXXXXXX;instance=SQLEXPRESS;";
String username = "XX";
String password = "XXXXXXX";
String sql = "";
conn = DriverManager.getConnection(connString, username, password);
a++;
Statement stmt = conn.createStatement();
a++;
sql = "Select * from NUMBERFILE";
ResultSet reset = stmt.executeQuery(sql);
a++;
while(reset.next())
{
tDisplayS.setText(reset.getString("NUMBER").toString());
}
}
catch(Exception e)
{
Toast.makeText(getApplicationContext(), e.getMessage() + " " + a, Toast.LENGTH_LONG).show();
}
I used "a" to indicate where it would stop then it only has a value of 1 so meaning it cant establish connection.. I already searched for similar problems with mine but still no luck..
Please help.. appreciate all your reply..
Thanks!