SimpleJdbcInsert with MySQL

This is the matching code I wrote:

new SimpleJdbcInsert(dataSource)
    .withSchemaName("test")
    .withTableName("tableName")
    .usingGeneratedKeyColumns("idColumn");

      

When I call executeAndReturnKey(parameters)

, I read this in the console:

WARN [Org.springframework.jdbc.core.metadata.TableMetaDataProvider: locateTableAndProcessMetaData: 336] (main :) Cannot find table metadata for "tableName" - column names must be provided

Why is this happening? I know I can manually specify the column names, but this is not a question of using JdbcSimpleInsert I believe.

  • MySQL version 5.5.9
  • MySQL / J connector 5.1.23
  • Spring 3.2.1
+3


source to share


2 answers


When you run the same query on another MySQL server I ran into this error: java.sql.SQLException: Parameter metadata not available for the given statement

.
So I killed the birds with a stone :)



So, just add generateSimpleParameterMetadata=true

the JDBC connection to the url and everything will work as expected.

0


source


I got the same error for a different reason. In my JDBC connection string, I have listed the schema. So the suggestion withSchemaName

caused this error. When I removed it the insert worked.



0


source







All Articles