PreparedStatementCallback; SQL [insert into person values(?,?,?)]; ORA-01722: 无效数字
log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).
log4j:WARN Please initialize the log4j system properly.
here
Exception in thread "main" org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into person values(?,?,?)]; ORA-01722: 无效数字
; nested exception is java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字
Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: 无效数字
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1008)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1307)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3530)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:745)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:538)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:739)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:762)
at org.springframework.jdbc.object.SqlUpdate.update(SqlUpdate.java:168)
at com.pb.personDaoImpl.JDBCTemplatePersonDaoImpl.insert(JDBCTemplatePersonDaoImpl.java:35)
at com.pb.personEntity.test.Test.test1(Test.java:30)
at com.pb.personEntity.test.Test.main(Test.java:18)
解决方案:
如上图,oracle数据库的顺序是p_id,age,name;而我们在dao中的设置参数类型的时候也一定要遵循数据库的顺序。
insert into person values(?,?,?);参数类型要一致。