0

说明 在调试模式和使用 Eclipse 时,此 Android 代码处理行: con = DriverManager.getConnection(connectionUrl); 它会在 Logcat 中产生错误,例如:

错误

Could not find class 'java.sql.SQLFeatureNotSupportedException', referenced from method com.microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf
02-09 08:15:46.325: W/dalvikvm(367): VFY: unable to resolve new-instance 828 (Ljava/sql/SQLFeatureNotSupportedException;) in Lcom/microsoft/sqlserver/jdbc/SQLServerConnection;
02-09 08:15:46.325: D/dalvikvm(367): VFY: replacing opcode 0x22 at 0x0003
02-09 08:15:46.325: D/dalvikvm(367): VFY: dead code 0x0005-000e in Lcom/microsoft/sqlserver/jdbc/SQLServerConnection;.createArrayOf (Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;
02-09 08:15:46.385: I/dalvikvm(367): Failed resolving Lcom/microsoft/sqlserver/jdbc/SQLServerNClob; interface 818 'Ljava/sql/NClob;'
02-09 08:15:46.385: W/dalvikvm(367): Link of class 'Lcom/microsoft/sqlserver/jdbc/SQLServerNClob;' failed
02-09 08:15:46.395: E/dalvikvm(367): Could not find class 'com.microsoft.sqlserver.jdbc.SQLServerNClob', referenced from method com.microsoft.sqlserver.jdbc.SQLServerConnection.createNClob
02-09 08:15:46.395: W/dalvikvm(367): VFY: unable to resolve new-instance 563 (Lcom/microsoft/sqlserver/jdbc/SQLServerNClob;) in Lcom/microsoft/sqlserver/jdbc/SQLServerConnection;

代码 这只是这个类的一部分:

import java.sql.*;

public class ConnectURL {

    public static void main() {

        // Create a variable for the connection string.
        String connectionUrl = "jdbc:sqlserver://192.168.1.20:1433;" +
            "databaseName=BD;user=sa;password=pass1;integratedSecurity=true;";

        // Declare the JDBC objects.
        Connection con = null;
        Statement stmt = null;
        ResultSet rs = null;

            try {
                // Establish the connection.
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                con = DriverManager.getConnection(connectionUrl);
....

注意我已经在一个文件夹中下载了 Microsoft sqlserver jdbc 4.0,并且在这个项目中有一个带有这个路由的 Java 构建路径。

4

1 回答 1

0

java.sql.SQLFeatureNotSupportedException仅从 API 级别 9 开始可用。

我猜您的目标是较低的 API 级别。

于 2013-02-09T09:15:57.930 回答