I try to create connection between android app and sql server. I have in main activity:
Connect cn = new Connect();
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +"databaseName=UNIVERSITY;";
cn.dbConnect(connectionUrl,"","");
And Connect class is:
import java.sql.*;
import android.util.Log;
import javax.sql.*;
public class Connect {
public Connect() {}
public boolean dbConnect(String db_connect_string,String db_userid, String db_password)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
return true;
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
}
I also add sqljdbc.jar file.but i see in logcat:
01-30 19:04:22.747: E/dalvikvm(1618): Could not find class 'javax.sql.XAConnection', referenced from method com.microsoft.sqlserver.jdbc.SQLServerConnection.close
01-30 19:04:22.747: W/dalvikvm(1618): VFY: unable to resolve instanceof 235 (Ljavax/sql/XAConnection;) in Lcom/microsoft/sqlserver/jdbc/SQLServerConnection;
01-30 19:04:22.757: D/dalvikvm(1618): VFY: replacing opcode 0x20 at 0x0037
I Google a lot but didn't find the reason of this error.please help.