【发布时间】:2014-03-26 13:07:30
【问题描述】:
我应该如何将大字节数组插入 Informix blob 列?现在我有疑问:
INSERT INTO TABLE (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN_BLOB)
VALUES(?, ?, ?, ?, ?)
抛出一个非常奇怪的异常:
org.sqlproc.engine.SqlProcessorException: SQL ' INSERT INTO TABLE (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLOMN_BLOB ) VALUES(?, ?, ?, ?, ?)'. org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar []; nested exception is java.sql.SQLException: The specified table (into) is not in the database.
Caused by: java.sql.SQLException: The specified table (into) is not in the database.
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3545)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3871)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2661)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2577)
at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5981)
at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5892)
at com.informix.jdbc.IfxSmartBlob.IfxLoColInfo(IfxSmartBlob.java:306)
at com.informix.jdbc.IfxSmBlob.i(IfxSmBlob.java:787)
at com.informix.jdbc.IfxSmBlob.a(IfxSmBlob.java:520)
at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:291)
at com.informix.jdbc.IfxStatement.c(IfxStatement.java:1275)
at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:418)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.sqlproc.engine.spring.SpringQuery$9.doInPreparedStatement(SpringQuery.java:454)
at org.sqlproc.engine.spring.SpringQuery$9.doInPreparedStatement(SpringQuery.java:448)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
... 44 more
Caused by: java.sql.SQLException: ISAM error: no record found.
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:412)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3876)
... 59 more
我正在使用sqlProcessor,它使用准备好的语句将 blob 插入表中:
@Override
public void set(PreparedStatement st, int index, Object value) throws SQLException {
byte[] bytes = (byte[]) value;
st.setBytes(index, bytes);
}
DDL:
CREATE TABLE table1 (
COLUMN1 BIGINT ,
COLUMN2 VARCHAR(30) ,
COLUMN3 INTEGER ,
COLUMN4 INTEGER ,
COLUMN_BLOB blob
);
Informix 服务器是在 AIX 7.1 上运行的 Informix 12.10。
更新
好的,我解决了第一个问题。 sql 以空格开头,这对于informix 来说可能是个问题。但现在我有另一个例外:
Caused by: org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [IX000]; error code [-9810]; Smart-large-object error.; nested exception is java.sql.SQLException: Smart-large-object error.
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
at org.sqlproc.engine.spring.SpringQuery.updateWithoutGenKeys(SpringQuery.java:448)
at org.sqlproc.engine.spring.SpringQuery.update(SpringQuery.java:293)
... 42 more
Caused by: java.sql.SQLException: Smart-large-object error.
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:412)
at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3549)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3871)
at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2661)
at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2577)
at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5981)
at com.informix.jdbc.IfxSqli.executeFastPath(IfxSqli.java:5892)
at com.informix.jdbc.IfxSmartBlob.IfxLoCreate(IfxSmartBlob.java:376)
at com.informix.jdbc.IfxSmBlob.i(IfxSmBlob.java:790)
at com.informix.jdbc.IfxSmBlob.a(IfxSmBlob.java:520)
at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:291)
at com.informix.jdbc.IfxStatement.c(IfxStatement.java:1275)
at com.informix.jdbc.IfxPreparedStatement.executeUpdate(IfxPreparedStatement.java:418)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.sqlproc.engine.spring.SpringQuery$9.doInPreparedStatement(SpringQuery.java:454)
at org.sqlproc.engine.spring.SpringQuery$9.doInPreparedStatement(SpringQuery.java:448)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
... 44 more
Caused by: java.sql.SQLException: Smart Large Objects: No sbspace number specified.
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:412)
at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3876)
... 59 more
【问题讨论】:
-
你能在没有最后一个 BLOB 列的情况下插入数据吗?还向我们展示如何定义此列。你用的是哪种
BLOB?使用CREATE TABLE、两列和INSERT创建简单示例。向我们展示 Informix 版本和 JDBC 驱动程序版本。 -
ddl 已更新。当我想念 blobl 列插入工作正常时,当我想添加只是 blol 异常时是一样的
-
平台和版本是什么意思?我正在使用 informix db 12.10 版
-
这就是我的意思:哪个版本的 Informix 服务器(您说的 12.10),哪个版本的 Informix JDBC 驱动程序(可能是 CSDK 4.10 附带的版本)以及您在哪个操作系统上运行它?我不是 JDBC 专家,但给出的错误消息(加上省略 BLOB 列时它起作用的事实)表明存在严重错误;我建议联系您的支持渠道(最终是 IBM/Informix 技术支持)寻求建议。
-
嗯我不确定。 AIX 7.1 这可以是你想要的吗?