Unverified 提交 fc4c27b1 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #986 from katzyn/addBatch

Check parameters in JdbcPreparedStatement.addBatch()
...@@ -1329,6 +1329,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements ...@@ -1329,6 +1329,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements
Value[] set = new Value[size]; Value[] set = new Value[size];
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
ParameterInterface param = parameters.get(i); ParameterInterface param = parameters.get(i);
param.checkSet();
Value value = param.getParamValue(); Value value = param.getParamValue();
set[i] = value; set[i] = value;
} }
......
...@@ -13,6 +13,8 @@ import java.sql.PreparedStatement; ...@@ -13,6 +13,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.h2.api.ErrorCode;
import org.h2.test.TestBase; import org.h2.test.TestBase;
/** /**
...@@ -210,6 +212,7 @@ public class TestBatchUpdates extends TestBase { ...@@ -210,6 +212,7 @@ public class TestBatchUpdates extends TestBase {
String s = COFFEE_UPDATE; String s = COFFEE_UPDATE;
trace("Prepared Statement String:" + s); trace("Prepared Statement String:" + s);
prep = conn.prepareStatement(s); prep = conn.prepareStatement(s);
assertThrows(ErrorCode.PARAMETER_NOT_SET_1, prep).addBatch();
prep.setInt(1, 2); prep.setInt(1, 2);
prep.addBatch(); prep.addBatch();
prep.setInt(1, 3); prep.setInt(1, 3);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论