This is the relevan code I wrote:
new SimpleJdbcInsert(dataSource)
.withSchemaName("test")
.withTableName("tableName")
.usingGeneratedKeyColumns("idColumn");
When I call the executeAndReturnKey(parameters)
I read this on the console:
WARN [org.springframework.jdbc.core.metadata.TableMetaDataProvider:locateTableAndProcessMetaData:336] (main:) Unable to locate table meta data for 'tableName' -- column names must be provided
Why does this happen? I know I can manually specify column names, but it's not the point of using JdbcSimpleInsert, I believe.
While executing the same query on a different MySQL server, I've came across this error: java.sql.SQLException: Parameter metadata not available for the given statement
.
So I've killed to birds with a stone :)
So, just add generateSimpleParameterMetadata=true
to the JDBC connection URL and everything will work as expected.
I got an identical error, for a different reason. In my JDBC connection string, I listed the schema. Therefore, putting the withSchemaName
clause caused this error. When I removed it, the insert worked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.