3

我尝试在 android app 和 sql server 之间创建连接。我的主要活动是:

Connect cn = new Connect();
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +"databaseName=UNIVERSITY;";
cn.dbConnect(connectionUrl,"","");

Connect 类是:

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;
        }
    }
}

我还添加了 sqljdbc.jar 文件。但我在 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

我谷歌了很多,但没有找到这个错误的原因。请帮助。

4

0 回答 0