Jfinal 处理oracle CLOB

绝望的八皮 发布于 2012/09/28 11:28
阅读 1K+
收藏 1
	public CommandMission findLastCommandMissionByDevId(String devId)  {
		return findFirst("SELECT * FROM D_COMMANDMISSION WHERE DEVID = ? AND COMMANDSTATUS = 1 AND nvl(MESSAGE,'')!='' ORDER BY LASTTIME",devId);
	}

我有这样一个方法,其中message为clob,如果这个devid查出数据能正常返回,如果没有数据就会报以下异常

com.jfinal.plugin.activerecord.ActiveRecordException: java.sql.SQLException: ORA-00932: 数据类型不一致: 应为 -, 但却获得 CLOB

at com.jfinal.plugin.activerecord.Model.find(Model.java:419)
at com.jfinal.plugin.activerecord.Model.findFirst(Model.java:448)
at com.cloud.dm.commandmission.CommandMission.findLastCommandMissionByDevId(CommandMission.java:12)
at com.cloud.dm.commandmission.CommandMission$findLastCommandMissionByDevId.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at test.com.cloud.dm.commandMission.CommandMissionTest.testFindLastCommandMissionByDevId(CommandMissionTest.groovy:16)
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:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at test.com.cloud.base.JfinalBaseDbUnitTestCase$DataSetsTemplateRunner$AssertDataSetStatement.evaluate(JfinalBaseDbUnitTestCase.java:185)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
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-00932: 数据类型不一致: 应为 -, 但却获得 CLOB

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1124)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:182)
at com.jfinal.plugin.activerecord.Model.find(Model.java:400)
at com.jfinal.plugin.activerecord.Model.find(Model.java:417)
... 33 more

加载中
0
绝望的八皮
绝望的八皮

好吧我错了 。。

 nvl(MESSAGE,'')  这里处理错了。。

0
绝望的八皮
绝望的八皮
又试了一下,应该是当记录中clob为null的时候报错
返回顶部
顶部