the exception is misleading to debug, i fixed it, since date field is mandatory and dont accept null. i was inserting null. it worked upon giving data
Mysql insert query not working on insert
-
01-07-2022 - |
Pergunta
i am getting JDBC 3.0 getParameterType call not supported exception, when trying to insert query into mysql. getting below exception
2013-10-26 20:04:25 [http-apr-8080-exec-9] DEBUG [org.springframework.jdbc.core.StatementCreatorUtils] - - JDBC 3.0 getParameterType call not supported
java.sql.SQLException: Parameter metadata not available for the given statement
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)
at com.mysql.jdbc.MysqlParameterMetadata.checkAvailable(MysqlParameterMetadata.java:70)
at com.mysql.jdbc.MysqlParameterMetadata.getParameterType(MysqlParameterMetadata.java:119)
at org.springframework.jdbc.core.StatementCreatorUtils.setNull(StatementCreatorUtils.java:231)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:213)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:144)
at org.springframework.jdbc.core.ArgumentPreparedStatementSetter.doSetValue(ArgumentPreparedStatementSetter.java:65)
at org.springframework.jdbc.core.ArgumentPreparedStatementSetter.setValues(ArgumentPreparedStatementSetter.java:46)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:822)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:589)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:874)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:882)
i am using spring 3.2.4 tomcat 7 and mysql connector 5.1.26. It appears strange for me , because i have other daos which does insert and select.
when i run junit test case, i could successfully insert the data.
help needed. thanks.
EDIT- code causing the error
jdbcTemplate.update(
ADD_DATA,
new Object[] { IdKey, model.getType(), model.getUserId(), model.getDate(),
model.getPlace(), model.getArea(); ,model.getAddressBO().getCity(), model.getAddressBO().getState() });
sql query
INSERT INTO model (model_ID, model_TYPE_ID, USER_ID, model_DATE, model_PLACE, model_AREA, CITY_ID, STATE_ID) VALUES (?, ?, ? ,?, ?, ?, ? ,?) ";
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow