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

Auto-generated keys are not returned if they're requested by column names or indexes

    XMLWordPrintable

    Details

      Description

      org.mariadb.jdbc.Connection.prepareStatement(String sql, int columnIndexes[]) and prepareStatement(String sql, String columnNames[]) call prepareStatement(sql), which in turn calls prepareInternal() with Statement.NO_GENERATED_KEYS, while it should request auto-generated keys using Statement.RETURN_GENERATED_KEYS.

      Excerpt from JDBC Connection javadoc for these methods: "Creates a default PreparedStatement object capable of returning the auto-generated keys".

      This leads to INSERTs to fail with SQLException: "Cannot return generated keys: query was not set with Statement.RETURN_GENERATED_KEYS".

      In particular, this makes Spring JDBC SimpleJdbcInsert unusable as under the cover prepareStatement(String sql, String columnNames[]) gets called.

        Attachments

          Activity

            People

            Assignee:
            diego dupin Diego Dupin
            Reporter:
            oleg.n.alex Oleg Alexeyev
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.