NutzCN Logo
问答 oracle 更新Clob字段出错
发布于 2755天前 作者 qqfe28902f 3632 次浏览 复制 上一个帖子 下一个帖子
标签:

对应实体配置的是Clob

UPDATE  table SET xml_info=? ... WHERE record_no=?'
CaseMessage=ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

有没得方法处理这种超过4k的xml文本?

20 回复

用什么语句更新的?

来自炫酷的 NutzCN

String xml=Files.read(new File("d:\1.xml"));
pic.setXml_info(new SerialClob(xml.toCharArray()));
dao.update(Picture_info.class, Chain.make("xml_info", new SerialClob(xml.toCharArray())), Cnd.where("record_no", "=", "111"));

xml_info这个java属性的类型是Clob吗?

来自炫酷的 NutzCN

	@Column
	private Clob xml_info;

是的

试试用pojo的方式update,感觉像个bug

来自炫酷的 NutzCN

试过了,还是一样的,还有其他的方式操作clob字段不

难道用的是非常老的nutz版本?

来自炫酷的 NutzCN

最新版本 nutz-1.r.61.r2

SerialClob改成SimpleClob试试

来自炫酷的 NutzCN

	SimpleClob clob=new SimpleClob();
    	clob.setString(0, xml);
    	pic.setXml_info(clob);

报错

java.lang.RuntimeException: Not implement yet!
	at org.nutz.lang.Lang.noImplement(Lang.java:110)
	at org.nutz.dao.util.blob.SimpleClob.setString(SimpleClob.java:66)
	at com.gd.common.test.SimpleTest.test_pic_service(SimpleTest.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

是不是赋值没对?

SimpleClob.setFile

来自炫酷的 NutzCN

不对呢,SimpleClob的构造方法参数就是File,import错了?

来自炫酷的 NutzCN

 		SimpleClob clob=new SimpleClob(new File("d:\\1.xml"));

但是还是报 这个CaseMessage=ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

oracle版本多少,驱动版本多少,我晚上测一下,感觉不可能啊

来自炫酷的 NutzCN

10g,ojdbc6.jar ,Oracle JDBC Driver version - "11.1.0.7.0-Production"

把报错信息也完整贴一下

来自炫酷的 NutzCN

2017-06-07 17:40:14,713 org.nutz.dao.jdbc.Jdbcs.getExpert(Jdbcs.java:103) INFO  - Get Connection from DataSource for JdbcExpert, if you lock at here, check your database server and configure
org.nutz.dao.DaoException: !Nutz SQL Error: 'UPDATE PICTURE_INFO SET xml_info='*Clob(len=8662)'  WHERE record_no='111''
PreparedStatement: 
'UPDATE PICTURE_INFO SET xml_info=?  WHERE record_no=?'
CaseMessage=ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:104)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:66)
	at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
	at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:64)
	at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:139)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:158)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:125)
	at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:92)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:81)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:245)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:257)
	at org.nutz.dao.impl.EntityOperator.exec(EntityOperator.java:55)
	at org.nutz.dao.impl.NutDao.update(NutDao.java:299)
	at com.gd.common.test.SimpleTest.test_pic_service(SimpleTest.java:107)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:33)
	at org.nutz.mock.NutTestRunner.runChild(NutTestRunner.java:14)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.SQLException: ORA-01461: 仅能绑定要插入 LONG 列的 LONG 值

	at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
	at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1034)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
	at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3488)
	at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2931)
	at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
	at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2929)
	at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:131)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:493)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runPreparedStatement(NutDaoExecutor.java:308)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:90)
	... 37 more

日志也贴上

2017-06-07 21:12:39,130 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - DROP TABLE t_update_clob_blob
2017-06-07 21:12:39,130 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,157 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=27ms, sql=DROP TABLE t_update_clob_blob
2017-06-07 21:12:39,158 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - DROP SEQUENCE t_update_clob_blob_id_SEQ
2017-06-07 21:12:39,158 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,162 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=4ms, sql=DROP SEQUENCE t_update_clob_blob_id_SEQ
2017-06-07 21:12:39,166 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - CREATE TABLE t_update_clob_blob(
id NUMBER(8) primary key ,
manytext CLOB,
manybinary BLOB)
2017-06-07 21:12:39,166 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,179 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=13ms, sql=CREATE TABLE t_update_clob_blob(
id NUMBER(8) primary key ,
manytext CLOB,
manybinary BLOB)
2017-06-07 21:12:39,179 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - CREATE SEQUENCE t_update_clob_blob_id_SEQ  MINVALUE 1 MAXVALUE 999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
2017-06-07 21:12:39,179 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,183 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=3ms, sql=CREATE SEQUENCE t_update_clob_blob_id_SEQ  MINVALUE 1 MAXVALUE 999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
2017-06-07 21:12:39,183 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - create or replace trigger t_update_clob_blob_id_ST BEFORE INSERT ON t_update_clob_blob FOR EACH ROW BEGIN  IF :new.id IS NULL THEN SELECT t_update_clob_blob_id_seq.nextval into :new.id FROM dual; END IF; END t_update_clob_blob_id_ST;
2017-06-07 21:12:39,183 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,192 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=9ms, sql=create or replace trigger t_update_clob_blob_id_ST BEFORE INSERT ON t_update_clob_blob FOR EACH ROW BEGIN  IF :new.id IS NULL THEN SELECT t_update_clob_blob_id_seq.nextval into :new.id FROM dual; END IF; END t_update_clob_blob_id_ST;
2017-06-07 21:12:39,204 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - INSERT INTO t_update_clob_blob(manytext,manybinary) VALUES(?,?) 
    |                1 |                          2 |
    |------------------|----------------------------|
    | *Clob(556645142) | *Blob(hascode=-1284718889) |
  For example:> "INSERT INTO t_update_clob_blob(manytext,manybinary) VALUES('*Clob(556645142)','*Blob(hascode=-1284718889)') "
2017-06-07 21:12:39,204 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,265 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=61ms, sql=INSERT INTO t_update_clob_blob(manytext,manybinary) VALUES('*Clob(556645142)','*Blob(hascode=-1284718889)') 
2017-06-07 21:12:39,265 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT MAX(id) AS id FROM t_update_clob_blob
2017-06-07 21:12:39,266 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,275 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=8ms, sql=SELECT MAX(id) AS id FROM t_update_clob_blob
2017-06-07 21:12:39,278 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - UPDATE t_update_clob_blob SET manytext=?,manybinary=?  WHERE id=?
    |                  1 |                        2 | 3 |
    |--------------------|--------------------------|---|
    | *Clob(-1896958123) | *Blob(hascode=-55594092) | 1 |
  For example:> "UPDATE t_update_clob_blob SET manytext='*Clob(-1896958123)',manybinary='*Blob(hascode=-55594092)'  WHERE id=1"
2017-06-07 21:12:39,278 org.nutz.dao.impl.interceptor.SayHiDaoInterceptor.filter(SayHiDaoInterceptor.java:15) DEBUG - nop ...
2017-06-07 21:12:39,283 org.nutz.dao.impl.interceptor.DaoTimeInterceptor.filter(DaoTimeInterceptor.java:28) DEBUG - time=5ms, sql=UPDATE t_update_clob_blob SET manytext='*Clob(-1896958123)',manybinary='*Blob(hascode=-55594092)'  WHERE id=1
添加回复
请先登陆
回到顶部