昨天,在系统修改了一下SQL,报出了这样一个异常。网上找了一下资料,大部分是说驱动的版本太旧,需要升级。
Caused by: java.sql.SQLException: OALL8 处于不一致状态 at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)?
但是目前的情况是:
1、仅修改SQL语句被修改过,驱动不变。——证明非驱动问题
2、设置更有大的回滚字段,但由于没有管理员权限,此路无法验证。
3、只有在使用like情况,且最终有数据下才出现。出现异常后,会导致其他SQL也出现异常,表现为
11/05/25 09:43:47 ERROR [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] JDBCTransaction.rollback(168) | JDBC rollback failedjava.sql.SQLRecoverableException: 无法从套接字读取更多的数据 at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)?
select * from (select EIPOD_ID, /*委托订单主键*/ EIPOD_BK_VESSEL, /*船名*/ EIPOD_BK_VOYAGE, /*航次*/ EIPOD_WB_NO, /*运单号*/ EIPOD_DISC_PORT_ID, /*卸载港*/ EIPOD_CONSIGNEE_NAME, /*收货人名称*/ CNT_NOS, /*集装箱号*/ GROSS_WEIGHT, /*毛重*/ EXECUTIVES, /*运箱人*/ ADDRESSES, /*地址*/ RELEASE_WEIGHT /*实际毛重*/ from (select EIPOD.CREATE_TIME, EIPOD.EIPOD_ID, /*委托订单主键*/ EIPOD.EIPOD_BK_VESSEL, /*船名*/ EIPOD.EIPOD_BK_VOYAGE, /*航次*/ EIPOD.EIPOD_WB_NO, /*运单号*/ EIPOD.EIPOD_DISC_PORT_ID, /*卸载港*/ EIPOD.EIPOD_CONSIGNEE_NAME, /*收货人名称*/ GET_CNT_NO(EIPOD.EIPOD_ID, ',') CNT_NOS, /*集装箱号*/ nvl((select sum(EIPCI.EIPCI_GROSS_WEIGHT) from EIP_CTNINFO EIPCI where EIPCI.EIPCI_EIPOD_ID = EIPOD.EIPOD_ID), 0) GROSS_WEIGHT, /*毛重*/ GET_DELIVER_EXECUTIVES(EIPOD.EIPOD_ID, ',') EXECUTIVES, /*运箱人*/ GET_DELIVER_ADDRESSES(EIPOD.EIPOD_ID, ',') ADDRESSES, /*地址*/ nvl((select sum(EIPMP_GROSS_WEIGHT) from EIP_MUTIL_PLACE EIPMP where exists (select 1 from EIP_CTNINFO EIPCI where EIPCI.EIPCI_ID = EIPMP.EIPMP_EIPCI_ID and EIPCI.EIPCI_EIPOD_ID = EIPOD.EIPOD_ID)), 0) RELEASE_WEIGHT /*实际毛重*/ from EIP_ORDER EIPOD left join SCH_VOYAGE SCHVO on EIPOD.EIPOD_SCHVO_ID = SCHVO.SCHVO_ID left join VES_SHIP_BASE_INFO VESSI on SCHVO.SCHVO_VESSEL_ID = VESSI.VESSI_ID where EIPOD.EIPOD_BK_CONFIRMED_FLAG = '4' /*订舱状态为确认*/ and EIPOD.EIPOD_IS_VALID != '0' /*0-非数据逻辑删除*/ and EIPOD.EIPOD_WB_NO like 'SUN1104230007' || '%' and (( 1=1 )) /*数据权限*/ ) where GROSS_WEIGHT > 0 order by CREATE_TIME desc /*按时间倒叙排列*/) where rownum <= 20?
通过不断的测试,发现CROSS_WEIGHT这个条件起到比较大的作用。回想到回滚字段问题,猜测有可能是CROSS_WEIGHT是使用select子查询的的原因。
修改将select子查询修改为left join (子查询)的方式。测试通过。可以推论确实是由于select子查询引起的,这样的子查询可能是导致了大量的回滚段数据。
问题已经解决,接下去工作是找出两种查询的真正差别是什么,性能如何?
?
?
from EIP_ORDER EIPOD left join SCH_VOYAGE SCHVO on EIPOD.EIPOD_SCHVO_ID = SCHVO.SCHVO_ID left join VES_SHIP_BASE_INFO VESSI on SCHVO.SCHVO_VESSEL_ID = VESSI.VESSI_ID left join (select EIPCI_EIPOD_ID,sum(EIPCI.EIPCI_GROSS_WEIGHT) EIPCI_GROSS_WEIGHT from EIP_CTNINFO EIPCI group by EIPCI.EIPCI_EIPOD_ID) EIP on EIP.EIPCI_EIPOD_ID = EIPOD.EIPOD_ID