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);
}
}
}
}