[CONJ-273] since 1.3.7 : You need to set exactly 1 parameters on the prepared statement Created: 2016-04-02  Updated: 2016-04-04  Resolved: 2016-04-04

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.4.0, 1.3.7
Fix Version/s: 1.4.1

Type: Bug Priority: Major
Reporter: sjachym Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

After MariaDB Connector/Java (CONJ) version 1.3.6 (since 1.3.7 and 1.4.0), the "INSERT INTO my_table (my_col) VALUES ('my_val')" failed :

{{ Exception in thread "main" java.sql.SQLException: You need to set exactly 1 parameters on the prepared statement
Query is : INSERT INTO my_table (my_col) VALUES ('my_val')null
at org.mariadb.jdbc.internal.util.ExceptionMapper. get(ExceptionMapper.java:136)
at org.mariadb.jdbc.internal.util.ExceptionMapper.throwException(ExceptionMapper.java:69)
at org.mariadb.jdbc.MariaDbStatement.executeQueryEpilog(MariaDbStatement.java:213)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternal(MariaDbClientPreparedStatement.java:185)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.execute(MariaDbClientPreparedStatement.java:129)
at com.placeoweb.TestSqlMariadbMysql.main(TestSqlMariadbMysql.java:108)
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: You need to set exactly 1 parameters on the prepared statement
Query is : INSERT INTO my_table (my_col) VALUES ('my_val')null
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQueries(AbstractQueryProtocol.java:698)
at org.mariadb.jdbc.MariaDbClientPreparedStatement.executeInternal(MariaDbClientPreparedStatement.java:177)
... 2 more}}

And for insert multiple rows insert statement "INSERT INTO my_table (my_col) VALUES ('my_val1'),('my_val2')", failed also :

{{Exception in thread "main" java.sql.SQLException: You need to set exactly 1 parameters on the prepared statement
Query is : INSERT INTO my_table (my_col) VALUES ('my_val1')null,('my_val2')
Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: You need to set exactly 1 parameters on the prepared statement
Query is : INSERT INTO my_table (my_col) VALUES ('my_val1')null,('my_val2')}}

Like the first case , CONJ is adding a "null" ( only after the first values declaration ), and broke the statement !
While the statement is working fine on the command line console.

Tests with mariadb-java-client-1.3.2.jar to mariadb-java-client-1.4.0.jar
Server : 10.0.23-MariaDB-0+deb8u1

private String urlJdbc = "jdbc:mysql://mariadb.devel/myDb";
Class.forName("org.mariadb.jdbc.Driver").newInstance();
connectionSQL = java.sql.DriverManager.getConnection(urlJdbc);

psUpdate = connectionSQL.prepareStatement("INSERT INTO my_table (my_col) VALUES ('my_val1'),('my_val2')");
psUpdate.execute();

http://dotclear.placeoweb.com/post/MariaDB-Connector/Java-You-need-to-set-exactly-1-parameters-on-the-prepared-statement



 Comments   
Comment by Diego Dupin [ 2016-04-04 ]

reproduced and corrected by commit : https://github.com/MariaDB/mariadb-connector-j/commit/968f92b745e767efdb10ec2ca4fd2819a4239c7e
This will be in a correction release 1.4.1 by the end of the week.

Generated at Thu Feb 08 03:14:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.