aws / amazon-redshift-jdbc-driver

Redshift JDBC Driver. It supports JDBC 4.2 specification.
Apache License 2.0
60 stars 30 forks source link

Redshift driver 2.1.0.11 is not supporting batch operation using jooq #82

Open muskaan62 opened 1 year ago

muskaan62 commented 1 year ago

Driver version

2.1.0.11

Client Operating System

ubuntu 20.04

JAVA/JVM version

open jdk 11.0.18

Problem description

Redshift driver is not supporting the batch operation with jooq(version 3.9.1) library..when trying to execute multiple statements at a time.

Error message/stack trace: Exception in thread "main" java.sql.BatchUpdateException: Batch entry 1 was aborted: Too many update results were returned. Call getNextException to see other errors in the batch. at com.amazon.redshift.jdbc.BatchResultHandler.handleError(BatchResultHandler.java:167) at com.amazon.redshift.jdbc.BatchResultHandler.handleCommandStatus(BatchResultHandler.java:108) at com.amazon.redshift.core.ResultHandlerDelegate.handleCommandStatus(ResultHandlerDelegate.java:40) at com.amazon.redshift.core.v3.QueryExecutorImpl$1.handleCommandStatus(QueryExecutorImpl.java:669) at com.amazon.redshift.core.v3.QueryExecutorImpl.interpretCommandStatus(QueryExecutorImpl.java:2650) at com.amazon.redshift.core.v3.QueryExecutorImpl.processResultsOnThread(QueryExecutorImpl.java:2150) at com.amazon.redshift.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1874) at com.amazon.redshift.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1866) at com.amazon.redshift.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:593) at com.amazon.redshift.jdbc.RedshiftStatementImpl.internalExecuteBatch(RedshiftStatementImpl.java:984) at com.amazon.redshift.jdbc.RedshiftStatementImpl.executeBatch(RedshiftStatementImpl.java:1012) at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:93) at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:93) at org.jooq.impl.BatchMultiple.execute(BatchMultiple.java:106) at org.jooq.impl.BatchMultiple.execute(BatchMultiple.java:78) at Main.main(Main.java:39) Caused by: com.amazon.redshift.util.RedshiftException: Too many update results were returned. ... 15 more

Reproduction code

String q = "insert into public.multi_test_Testtable values(111);insert into public.multi_test_Testatble values(222);"; DSLContext context = DSL.using(con, SQLDialect.REDSHIFT); Query Q1 = context.query(q); arrayList.add(Q1); batch= context.batch(arrayList); try { result = batch.execute(); } catch (Throwable e) { if(e.getCause() instanceof BatchUpdateException) throw (BatchUpdateException)e.getCause(); }

bhvkshah commented 1 year ago

Thanks for submitting this issue, we will look into it and get back to you.