简体   繁体   中英

java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource

I am having a table with array datatype in postgres. I am inserting values using JDBC from my java class. But, unable to insert in that and getting the following error..

    [Handler processing failed; nested exception is java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;] with root cause
     java.lang.AbstractMethodError: org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.createArrayOf(Ljava/lang/String;[Ljava/lang/Object;)Ljava/sql/Array;
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.hibernate.jdbc.BorrowedConnectionProxy.invoke(BorrowedConnectionProxy.java:74)
        at com.sun.proxy.$Proxy41.createArrayOf(Unknown Source)
        at com.mmf.controllers.UpdateReconcileController.save(com.mmf.controllers.UpdateReconcileController:146)

My code is

        String querys = "insert into reconcile_process (process_type,fk_last_modified_by,fk_bank_stmt_id)"
                + " values (?,?,?)";
        Connection connections = sessionFactory.getCurrentSession().connection();
        CallableStatement stmts = connections.prepareCall(querys);
        stmts.setString(1, "Auto");
        stmts.setInt(2, 1);
        stmts.setArray(3, connections.createArrayOf("integer", idArrs));    -----// line 146
        stmts.executeUpdate(querys);;
        connections.close();

postgres table

    CREATE TABLE reconcile_process
    (
      id bigserial NOT NULL,
      fk_last_modified_by bigint NOT NULL,
      process_type character varying,
      fk_bank_stmt_id bigint[]
    )
    WITH (
      OIDS=FALSE
    );

These two things look promising: Answer here and Answer over there at postgres .

Possible the Driver does not support that, you can try to unwrap the Postgresql connection and then use that directly, like that (not 100% sure about the class name, you'll have to look inside the driver's jar to find that one)...

PGSQLConnection pgsqlConnection = null;
try {
    if (connection.isWrapperFor(PGSQLConnection .class)) {
        pgsqlConnection = connection.unwrap(PGSQLConnection .class);
    }
} catch (SQLException ex) {
    // do something
}

return oracleConnection;

I think that the problem is that the Driver you are using to connect to Postgres does not support all the DBCP methods (AbstractMethodError). Remember that DBCP uses the latest specifications for the standar, but you might be using a driver that does not support it.

What I would do is to upgrade the postgres driver jar to tha latest version and see if it matches DBCP specifications.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM