使用Hibernate / JPA在Oracle中关闭Connection时的部分提交

时间:2012-05-30 22:47:59

标签: hibernate jpa oracle11g c3p0

最近我的应用程序JPA / Hibernate中出现了以下错误,数据库为Oracle RAC 11g。

当我们的存储空间已满并且DBA需要关闭连接,杀死活动会话或某些类似“连接已关闭”(现在我可以知道发生了什么,他被解雇了......)时发生了此错误。

javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
at com.cgmp.ValePedagioSite.comprarViagemPorPlaca(ValePedagioSite.java:473)
at sun.reflect.GeneratedMethodAccessor1719.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
        (...)
Caused by: org.hibernate.exception.JDBCConnectionException: could not insert: [com.cgmp.model.entity.PedagioPracaViagem]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
        (...)
Caused by: java.sql.SQLRecoverableException: Connection closed
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3331)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:47)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3232)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:47)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
        (...)

其他实体插入没有问题......

--- EDITED ---

更多信息

配置c3p0

<Resource auth="Container"
description=""
driverClass="oracle.jdbc.driver.OracleDriver"
acquireIncrement="1"
initialPoolSize="5"
maxPoolSize="300"
minPoolSize="5"
maxIdleTime="600"
maxIdleTimeExcessConnections="300"
unreturnedConnectionTimeout="900"
numHelperThreads="20"
name=""
user=""
password=" "
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:oracle:oci:" />

与其他DBA交谈他说来自Oracle的一个实例获得了完整的磁盘,并且此时创建了部分提交的寄存器,但他刚刚删除了跟踪文件,没有停止db而不是杀死任何会议。

1 个答案:

答案 0 :(得分:1)

嗯,没有足够的信息可以肯定地说,但听起来就像你看到它没有完成的交易处理。 JDBC规范默默地讨论了在未完成的事务中应该发生什么的问题。 Oracle是我所知道的唯一一个决定最佳行动方案的供应商,就是在这种情况下承诺工作。