Home  >  Forum  >  Spring
Post New Query

Column name pattern can not be NULL or empty



Asked on August 01, 2022
I am inserting data into MySQL using Spring SimpleJdbcInsert.


KeyHolder keyHolder = simpleJdbcInsert
.withTableName("person")
.usingColumns("name", "age")
.usingGeneratedKeyColumns("id")
.executeAndReturnKeyHolder(params);


Getting error .................

2022-08-01 13:57:01.005  WARN 6140 --- [           main] o.s.j.c.metadata.TableMetaDataProvider   : Error while retrieving meta-data for table columns. Consider specifying explicit column names -- for example, via SimpleJdbcInsert#usingColumns().

java.sql.SQLException: Column name pattern can not be NULL or empty.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545) ~[mysql-connector-java-6.0.5.jar:6.0.5]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513) ~[mysql-connector-java-6.0.5.jar:6.0.5]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505) ~[mysql-connector-java-6.0.5.jar:6.0.5]




Replied on August 01, 2022
I fixed it using withoutTableColumnMetaDataAccess() method.


KeyHolder keyHolder = simpleJdbcInsert
.withTableName("person")
.usingColumns("name", "age")
.usingGeneratedKeyColumns("id")
.withoutTableColumnMetaDataAccess()     
.executeAndReturnKeyHolder(params);




Write Answer











©2022 concretepage.com | Privacy Policy | Contact Us