You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Jacob Roldan (Jira)" <ji...@apache.org> on 2019/09/10 15:25:00 UTC
[jira] [Created] (CALCITE-3338) Error with executeBatch and
preparedStatement.
Jacob Roldan created CALCITE-3338:
-------------------------------------
Summary: Error with executeBatch and preparedStatement.
Key: CALCITE-3338
URL: https://issues.apache.org/jira/browse/CALCITE-3338
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.20.0
Environment: apache calcite 1.20
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Linux 4.15.0-60-generic #67-Ubuntu
Reporter: Jacob Roldan
I did a test similar to org.apache.calcite.jdbc.CalciteRemoteDriverTest#testInsertBatch but in this case using preparedStatement instead of statement:
{code:java}
@Test public void testInsertBatchWithPreparedStatement() throws Exception {
final Connection connection = DriverManager.getConnection(
"jdbc:avatica:remote:factory="
+ LocalServiceModifiableFactory.class.getName());
assertThat(connection.getMetaData().supportsBatchUpdates(), is(true));
assertThat(connection.isClosed(), is(false));
PreparedStatement pst = connection.prepareStatement("insert into \"foo\".\"bar\" values (?,?,?,?,?)");
pst.setInt(1,1);
pst.setInt(2,1);
pst.setString(3,"second");
pst.setInt(4,1);
pst.setInt(5,1);
pst.addBatch();
pst.addBatch();
int[] updateCounts = pst.executeBatch();
assertThat(updateCounts.length, is(2));
assertThat(updateCounts[0], is(1));
assertThat(updateCounts[1], is(1));
ResultSet resultSet = pst.getResultSet();
assertThat(resultSet, nullValue());
// Now empty batch
pst.clearBatch();
updateCounts = pst.executeBatch();
assertThat(updateCounts.length, is(0));
resultSet = pst.getResultSet();
assertThat(resultSet, nullValue());
connection.close();
}
{code}
And I got weird exceptions:
{noformat}
java.sql.SQLException at org.apache.calcite.avatica.Helper.createException(Helper.java:56) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaConnection.executeBatchUpdateInternal(AvaticaConnection.java:595) at org.apache.calcite.avatica.AvaticaPreparedStatement.executeLargeBatch(AvaticaPreparedStatement.java:266) at org.apache.calcite.avatica.AvaticaPreparedStatement.executeBatch(AvaticaPreparedStatement.java:259) at org.apache.calcite.jdbc.CalciteRemoteDriverTest.testInsertBatchWithPreparedStatement(CalciteRemoteDriverTest.java:876) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)Caused by: java.lang.NullPointerException at org.apache.calcite.runtime.SqlFunctions.cannotConvert(SqlFunctions.java:1534) at org.apache.calcite.runtime.SqlFunctions.toInt(SqlFunctions.java:1646) at Baz$2.apply(Unknown Source) at Baz$2.apply(Unknown Source) at org.apache.calcite.linq4j.EnumerableDefaults$10$1.current(EnumerableDefaults.java:1916) at org.apache.calcite.linq4j.EnumerableDefaults.into(EnumerableDefaults.java:2911) at org.apache.calcite.linq4j.DefaultEnumerable.into(DefaultEnumerable.java:340) at Baz.bind(Unknown Source) at org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:355) at org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:314) at org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:506) at org.apache.calcite.jdbc.CalciteMetaImpl.execute(CalciteMetaImpl.java:631) at org.apache.calcite.jdbc.CalciteMetaImpl.executeBatch(CalciteMetaImpl.java:652) at org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:365) at org.apache.calcite.avatica.remote.RemoteMeta$20.call(RemoteMeta.java:430) at org.apache.calcite.avatica.remote.RemoteMeta$20.call(RemoteMeta.java:427) at org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:793) at org.apache.calcite.avatica.remote.RemoteMeta.executeBatch(RemoteMeta.java:427) at org.apache.calcite.avatica.AvaticaConnection.executeBatchUpdateInternal(AvaticaConnection.java:593) ... 27 more{noformat}
--
This message was sent by Atlassian Jira
(v8.3.2#803003)