0

I searched many implementations, but none works for me. My DB is Oracle - V 12.1.0.2.0 (and my tool is PL/SQL).

And I get this error:

"java.rmi.ServerError: Unexpected Error; nested exception is: java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;

I read that this method (createArrayOf("NUMBER", data )) is not working for Oracle DB.

The method's param (listchopped) will have about 500 items and I don't want to iterate for each item of the list.

public void updateSMSCommandTable(List<Long> listchopped) throws AppException {
    Session sess = null;
    PreparedStatement stm = null;
    Transaction tx = null;
    OracleConnection oracleConnection = null;

    try {
        sess = hibSessionFactory.openSession();
        tx = sess.beginTransaction();
        Connection con = sess.connection();
        String sql = "update sms_commands2 set starthour=null,endhour=null where sms_command_id in (?)";


        final Long[] data = listchopped.toArray(new Long[listchopped.size()]);

        Array array = con.createArrayOf("NUMBER", data );


        stm = con.prepareStatement(sql);
        stm.setArray(0, array);
        stm.executeUpdate();
        tx.commit();

    } catch (Exception e) {
        try {
            if (tx != null)
                tx.rollback();
        } catch (HibernateException e1) {
            throw new AppException(e1);
        }
        throw new AppException(e);
    } finally {
        if (stm != null) {
            try {
                stm.close();
                stm = null;
            } catch (SQLException e) {
                throw new AppException(e);
            }
        }
        if (sess != null) {
            try {
                sess.close();
            } catch (HibernateException e) {
                throw new AppException(e);
            }
        }
    }
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mihai
  • 1
  • 2
    You're using a connection pool implementation that does not implement the `Connection.createArrayOf` method. Given this was introduced in JDBC 4 (Java 6), you may want to check if there is a newer version available that does support it, or consider switching to a different connection pool library. – Mark Rotteveel Oct 30 '18 at 09:24
  • But is normal to don't have a compile error? I'm using IntelliJ. – Mihai Oct 30 '18 at 09:46
  • in interface Connection a have this method: – Mihai Oct 30 '18 at 09:56
  • As an alternative, you migth find the helper methods shown from [here](https://github.com/fwi/fwutil-jdbc/blob/master/src/main/java/nl/fw/util/jdbc/DbConnUtil.java#L90) usefull (`preparePlaceHolders` and `setValues`). – vanOekel Oct 30 '18 at 10:11
  • @Mihai As explained by the duplicate this happens because the library you are using was compiled against JDBC 3.0 (Java 1.4, Java 5), which didn't have this method. If you then load that library, Java will allow that, but attempts to use the method defined in the interface will then raise an `AbstractMethodError`, because the method is not implemented in the library. Upgrade your library. – Mark Rotteveel Oct 30 '18 at 10:28
  • Unfortunately, I am not allowed to upgrade the library. Thx for advises. – Mihai Nov 01 '18 at 11:55

0 Answers0