Hi there! Having issues with stored procedures in new H2 version. This is the code to reproduce:
import java.math.BigInteger; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import org.h2.tools.SimpleResultSet; import org.junit.Test; public class H2StoredProcTests { @Test public void h2ParserProblem() throws SQLException { try (Connection connection = DriverManager.getConnection( "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=true", "sa", "")) { try (Statement statement = connection.createStatement()) { statement.execute("CREATE ALIAS GET_PRIME_NUMBERS FOR \" H2StoredProcTests.getPrimes\""); } try (CallableStatement callableStatement = connection.prepareCall("{ CALL GET_PRIME_NUMBERS(?, ?) }")) { callableStatement.setInt(1, 0); callableStatement.setInt(2, 10); callableStatement.execute(); } } } public static ResultSet getPrimes(int beginRange, int endRange) { SimpleResultSet rs = new SimpleResultSet(); rs.addColumn("PRIME", Types.INTEGER, 10, 0); for (int i = beginRange; i <= endRange; i++) { if (new BigInteger(String.valueOf(i)).isProbablePrime(100)) { rs.addRow(i); } } return rs; } } Works well in the previous 1.4.200 version. Looks like something has been broken in the org.h2.command.Parser and now it parsers params twice: [image: Params_screenshot.PNG] The failure in the end looks like this: org.h2.jdbc.JdbcSQLDataException: Parameter "#3" is not set; SQL statement: CALL GET_PRIME_NUMBERS(?, ?) [90012-206] at org.h2.message.DbException.getJdbcSQLException(DbException.java:665) at org.h2.message.DbException.getJdbcSQLException(DbException.java:496) at org.h2.message.DbException.get(DbException.java:227) at org.h2.message.DbException.get(DbException.java:203) at org.h2.expression.Parameter.checkSet(Parameter.java:75) at org.h2.command.Prepared.checkParameters(Prepared.java:181) at org.h2.command.CommandContainer.query(CommandContainer.java:254) at org.h2.command.Command.executeQuery(Command.java:190) at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:248) at H2StoredProcTests.h2ParserProblem(H2StoredProcTests.java:26) Thank you! Regards, Artem Bilan -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/h2-database/770ac492-c3ea-4a87-9c11-0c2bd615fc49n%40googlegroups.com.