gpt4 book ai didi

javascript - JDBC 错误 : AbstractMethodError: com. microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array

转载 作者:太空宇宙 更新时间:2023-11-04 14:16:49 25 4
gpt4 key购买 nike

您好,我只是从 SQL SERVER 选择数据并将其存储在结果集中。我遇到以下错误。

**JDBC ERROR : AbstractMethodError: com.microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array**

下面这行的问题

    java.sql.Array sqlarray = sqlcon.createArrayOf(null, rowValues.toArray());

我不确定为什么会出现此问题以及我应该传递 createArrayOf() 的确切参数。请帮助解决以下问题

这是我的完整代码

    public void getDatafromsql(ArrayList rowValues) throws SQLException,ClassNotFoundException 
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("SQL Server Start Connecting ");
Connection sqlcon = DriverManager
.getConnection(s_url, s_username, s_password);
System.out.println("Sql server Connection valid");
System.out.println(rowValues);
PreparedStatement s1 = sqlcon.prepareStatement("SELECT TOP 6 myid,document,name FROM table1 where DATEMODIFIED between ? and ? and myid in (?)");
s1.setTimestamp( 1,V_DOC_LAST_REFRESH_TIMESTAMP);
s1.setTimestamp( 2,V_DOC_CURRENT_REFRESH_TIMESTAMP);
//Below line throwing error
java.sql.Array sqlarray = sqlcon.createArrayOf(null, rowValues.toArray());
s1.setArray(3, sqlarray);
sql_rs = s1.executeQuery();
setdataOracle(sql_rs);
System.out.println("SQL Server Storage Completed ");
sqlcon.close();
}

最佳答案

SQL Server JDBC 驱动程序不支持该方法:

public java.sql.Array createArrayOf(String typeName,

Object[] elements) throws SQLException {

// Not implemented

throw new SQLFeatureNotSupportedException(SQLServerException.getErrString("R_notSupported"));

}

https://github.com/Microsoft/mssql-jdbc/blob/master/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java

而是使用 Table Valued Parameters ,或将数据传递为 XML , JSON ,或CSV并在服务器上解析它。

关于javascript - JDBC 错误 : AbstractMethodError: com. microsoft.sqlserver.jdbc.SQLServerConnection.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27620914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com