Not able to insert data in to AOT (Acclerated Only Table) table in IDAA server

240 views Asked by At

I'm trying to insert few records in to AOT tables from Java. Using DriverManager connection (by setting special register in connection URL) insertion is happening. But when using DataSource connection, INSERT query is getting failed with the below exception.

With the same DataSource connection, SELECT query is working fine for this AOT table.

com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-4742, SQLSTATE=560D5, SQLERRMC=24, DRIVER=4.24.92

I'm able to insert in to AOT from AQT Query tool. Should I add any additional configuration for INSERT query at Java side or DB Server side ? Java code inserting table is given below:

@Stateless
@LocalBean
public class MyDLService {

    @Resource(lookup = "jdbc/db2_schema")
    private DataSource dataSource;

    public void insert(Set<Key> keys) {
        try(Connection connection = dataSource.getConnection()) {
            PreparedStatement ps = connection.prepareStatement("INSERT INTO SCHEMA.AOT_TABLE (ID, CPOINT_ID) values (?,?)");
            int count = 0;
            for (Key key : keys) {
                ps.setLong(1, 1);
                ps.setLong(2, key.getPointId());
                ps.addBatch();

                if (++count % 1000 == 0) {
                    ps.executeBatch();
                }
            }
            ps.executeBatch();
            ps.close();
        } catch (SQLException e1) {
            e1.printStackTrace();
        }
}
0

There are 0 answers