0
说明 在调试模式下和使用Eclipse时这个代码为Android过程的行: CON =的DriverManager.getConnection(的ConnectionURL); 它产生logcat的一个错误,如:找不到类 'java.sql.SQLFeatureNotSupportedException'
错误
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构建路径。
是的,你是对的。现在我已经使用API> 8,并且未显示此错误。但现在有一个新的错误:01-29 11:54:20.387:E/dalvikvm(1137):无法找到类“javax.sql.XAConnection”,从方法引用com.microsoft.sqlserver.jdbc.SQLServerConnection.poolCloseEventNotify 01-29 11:54:20.387:W/dalvikvm(1137):VFY:无法解析Lcom/microsoft/sqlserver/jdbc/SQLServerConnection中的instanceof 913(Ljavax/sql/XAConnection; – 2013-02-12 10:36:30
如果它解决了问题,请接受(如果有帮助,请立即投诉)。关于XAConnection:这个类不是Android API的一部分。我想你需要它,因为你的事务管理器被配置为与多个数据库(或外部资源)一起工作。如果你真的需要这个功能:你将不得不寻找另一个不依赖'javax.sql.XAConnection'的驱动程序版本。如果您只有一个DB,则不需要此类,所以我建议您更深入地调查与您的驱动程序有关的可能配置问题。 – ben75 2013-02-12 10:47:57
对不起,当您写下“请接受...”时,您是否参考下面的按“是”按钮,其中标有“此帖是否??”。在这种情况下,我接受了它。所以,针对这个问题,我只在外部机器上有一个远程数据库,但这个类是必需的,所以看起来似乎。此外,我看到了这个错误的其他类似问题,它表明安装JEE的,所以我必须这样做,我已经能够添加导入javax.sql。*;但问题依然存在。 – 2013-02-12 11:37:21