【问题标题】:How to rectify the 'java.sql.SQLFeatureNotSupportedException' while using the createArrayOf() method如何在使用 createArrayOf() 方法时纠正“java.sql.SQLFeatureNotSupportedException”
【发布时间】:2013-03-22 14:03:57
【问题描述】:

我的代码如下:

        PreparedStatement pstm = con.prepareStatement("insert into parameter(Parameter) values(?)");
        Array a = con.createArrayOf("TEXT",s1);
        pstm.setArray(1,a);
        pstm.executeUpdate();

stacktrace如下:

   Exception in thread "main" java.sql.SQLFeatureNotSupportedException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.mysql.jdbc.SQLError.notImplemented(SQLError.java:1329)
at com.mysql.jdbc.JDBC4Connection.createArrayOf(JDBC4Connection.java:56)
at project.Project.main(Project.java:295)

请帮助我纠正这个问题。 提前谢谢你。

【问题讨论】:

    标签: java mysql jdbc


    【解决方案1】:

    http://docs.oracle.com/javase/6/docs/api/java/sql/SQLFeatureNotSupportedException.html

    这意味着你的mysql驱动不能做那个操作。要么使用不同的驱动程序/数据库,要么不使用该方法。

    【讨论】:

    • 还有什么其他方法可以完成我的任务?
    • 您还没有列出任务。从代码中,您希望将 Array 类型插入到数据库中。 According to the documentation,不支持 Array 类型,所以需要以不同的方式插入数据。
    • 我想将我的字符串数组(s1)插入到数据库中。
    • 不能,因为mysql不支持数组类型。这个答案可能会有所帮助。 stackoverflow.com/questions/12176709/…
    • 感谢大家提供的所有帮助。由于mysql中不能直接存储数组,所以我使用了setString()方法和for循环来存储字符串数组值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-26
    • 2015-11-22
    • 1970-01-01
    • 1970-01-01
    • 2019-08-24
    相关资源
    最近更新 更多