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
source to share
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.
source to share