Uploaded image for project: 'MariaDB Connector/J'
  1. MariaDB Connector/J
  2. CONJ-273

since 1.3.7 : You need to set exactly 1 parameters on the prepared statement

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 1.3.7
    • Fix Version/s: 1.4.1
    • Component/s: Other
    • 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

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            sjachym sjachym
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: