RROR: net.risesoft.risetransfer.bean.RowCallbackHandlerLobImpl - 执行错误;当前语句=insert into docexchange_docattachment(instance_guid,attachment_guid,attachment_name,attachment_title,attachment_type,attachment_extension,attachment_length,uploaddate,attachment_content)values(?,?,?,?,?,?,?,?,?)
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [insert into docexchange_docattachment(instance_guid,attachment_guid,attachment_name,attachment_title,attachment_type,attachment_extension,attachment_length,uploaddate,attachment_content)values(?,?,?,?,?,?,?,?,?)]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:615)
at net.risesoft.risetransfer.bean.RowCallbackHandlerLobImpl.processRow(RowCallbackHandlerLobImpl.java:36)
at org.springframework.jdbc.core.JdbcTemplate$RowCallbackHandlerResultSetExtractor.extractData(JdbcTemplate.java:1482)
at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:649)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:686)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:694)
at net.risesoft.risetransfer.manager.DataConvert.convertFormDoc(DataConvert.java:173)
at net.risesoft.risetransfer.manager.DataConvert.insertInbox(DataConvert.java:144)
at net.risesoft.risetransfer.manager.InitSystemListener.run(InitSystemListener.java:50)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: 表或视图不存在
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 com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
at net.risesoft.risetransfer.bean.PreparedStatementCallbackLobImpl.doInPreparedStatement(PreparedStatementCallbackLobImpl.java:52)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
... 14 more
原因:在数据库中这个表是存在的,但是由于语句中的attachment_content列为BLOB列 ; BLOB不能通过setObject或setBlob()直接设置;需要通过先进行插入empty_clob() 然后再写入;
因此需要将语句中的最后一个?改为empty_blob(); 然后再通过for update 的方式写入;或通过直接取得byte 数组;setBytes的方式进行插入