找不到类'java.sql.SQLFeatureNotSupportedException'

时间:2013-02-09 08:49:48

标签: android sql-server eclipse

描述 在Debug模式下使用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构建路径。

1 个答案:

答案 0 :(得分:0)

java.sql.SQLFeatureNotSupportedException仅在API级别9之后可用。

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