WLS 12C - Getting transaction is no longer active - java

I have configured Non-XA datasource in Weblogic and setAutoCommit(false) where few of my procedure have commit and configured transaction time in WLS for 5000
I am getting this exception
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:202)
at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:214)
at weblogic.jdbc.wrapper.JTSConnection.prepareCall(JTSConnection.java:610)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:451)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:375)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:310)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4855)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:4529)
at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3976)
at weblogic.jms.client.JMSSession.access$000(JMSSession.java:120)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5375)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
I am getting the below error message,
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:202)
at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:214)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:98)
at weblogic.jdbc.wrapper.JTSConnection_oracle_jdbc_driver_T4CConnection.physicalConnectionWithin(Unknown Source)
at oracle.sql.CLOB.createTemporary(CLOB.java:1118)
at oracle.sql.CLOB.createTemporary(CLOB.java:1078)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:451)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:375)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:310)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4855)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:4529)
at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3976)
at weblogic.jms.client.JMSSession.access$000(JMSSession.java:120)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5375)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
I am using the below code to insert data to a table,
java.sql.Clob clobData = oracle.sql.CLOB.createTemporary(conn,
false, oracle.sql.CLOB.DURATION_SESSION);

Related

Hibernate and Spring-boot too many database connection and high server load on 150 requests/second

I have spring boot application and I am using JPA and hibernate with oracle database. On high throughput 150 requests/second database stop allowing database connection and also database load goes unusually very high .
Here is my database configuration properties
spring.datasource.url=jdbc:oracle:thin:#<ip>:1521:<dbname>
spring.datasource.username=*******
spring.datasource.password=*******
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.initial-size=10
spring.datasource.maxActive=1200
spring.datasource.validationQuery=select 1 from dual
spring.jpa.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect
spring.jpa.show-sql = true
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.datasource.pool-prepared-statements=true
spring.datasource.pool-prepared-statements-cache-size=250
spring.datasource.max-open-prepared-statements=250
spring.datasource.max-idle=50
spring.datasource.min-idle=10
spring.datasource.time-between-eviction-runs-millis=30000
spring.datasource.min-evictable-idle-time-millis=60000
spring.datasource.suspect-timeout=60
spring.datasource.log-abandoned=true
Here is the exception that I am getting
Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
at net.bull.javamelody.JdbcWrapper$DelegatingInvocationHandler.invoke(JdbcWrapper.java:286)
at com.sun.proxy.$Proxy85.getConnection(Unknown Source)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:139)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:380)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:228)
... 21 more
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:392)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:434)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:687)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:247)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
... 40 more
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:150)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 45 more
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:431)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:427)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at net.bull.javamelody.MonitoringSpringInterceptor.invoke(MonitoringSpringInterceptor.java:73)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy133.updateDlrStatus(Unknown Source)
at com.acl.otp.thread.DlrRequestHandler.updateDLRStatus(DlrRequestHandler.java:39)
at com.acl.otp.thread.DlrRequestHandler.run(DlrRequestHandler.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:1771)
at org.hibernate.jpa.internal.TransactionImpl.begin(TransactionImpl.java:64)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:170)
at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:380)
... 14 more
Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:132)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:235)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:171)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doBegin(JdbcTransaction.java:67)
You appear to be overloading the database server / service.
There is no general solution to this (no "magic bullet"), but you could look at things like:
Limit the number of requests that you handle simultaneously.
Use a profiler or other monitoring to figure out the types of request that are causing excessive database load, and seeing if they are amenable to optimization by:
Optimizing the SQL and/or the database schema
Reducing the number of queries
Caching results of common queries.
Increase the resources (cores, memory, etc) available to the front end and / or the database; i.e. get bigger / faster machines.
Switch to native SQL rather than using JPA. (At least for the most heavily used queries.)
Rearchitect your application so that it can be "scaled out"; e.g. replicating the front-end and backend, using a non-SQL database, etc.
Note that none of these is guaranteed to work in all circumstances
the EntityManager related error occurs when the maximum connections reached to database. To resolve these type of errors "don't close session factory" in hibernate and close only session(must close) and make sure the "the connection pool size is less or otherwise leave to hibernate default connection pool size and use singleton design pattern to create sessionfactory object".

Maximum open cursors exceeded - with hibernate SchemaValidator

Our Oracle 11g database contains 298 tables(10 recently added), (+100 sequences), we declared 500 cursors.
When starting our WebApplication (Tomcat 7.0, jdbc pool), at sessionFactory initialization when hibernate validates schema it uses all cursors (cf below).
Is there anything known in order for hibernate to be less greedy with Oracle cursors ?
Please note that this problem has nothing to do with the handling of prepared statements or hibernate entities as I do not work with any of them at this step.
Caused by: org.hibernate.exception.GenericJDBCException: could not get table metadata: MYTABLE
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:105)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1080)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
... 34 more
Caused by: java.sql.SQLException: ORA-01000: maximum open cursors exceeded
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:774)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:925)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1111)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4845)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1501)
at oracle.jdbc.driver.OracleDatabaseMetaData.getColumnsWithWildcards(OracleDatabaseMetaData.java:350)
at oracle.jdbc.driver.OracleDatabaseMetaData.getColumns(OracleDatabaseMetaData.java:128)
at org.hibernate.tool.hbm2ddl.TableMetadata.initColumns(TableMetadata.java:146)
at org.hibernate.tool.hbm2ddl.TableMetadata.<init>(TableMetadata.java:32)
at org.hibernate.tool.hbm2ddl.DatabaseMetadata.getTableMetadata(DatabaseMetadata.java:90)
... 44 more
If your driver version is 12.1.0.2 then this is a known bug:
https://community.oracle.com/thread/3682300
In a nutshell: DatabaseMetaData.getTableTypes() creates a Statement but never closes it, it leaves the cursor open.
Most probably Hibernate calls getTableTypes() quite often during schema validation and thus you are affected by this bug.
The driver version 12.1.0.1 is not affected by this, so you might want to downgrade.
This is logged under Bug #19632480 so if you have access to MOS you can download a patch for this.

Protocol violation exception in Java application

We have an application developed in java(jdk1.5 and DB is oracle 10g). At some point of time our application is giving below error and terminating. I had searched in the internet and all forums says that "this could be the driver issue (compatibility between oracle JDBC driver and DB). To resolve this we need to upgrade or we need to replace some latest version of jar files". But if I restart my application, it started working fine. I am getting this error very rarely. If it is really an driver issue, then it should not work when I restart my application.
I would like to understand that, in which scenario it can happen, since it is not happening every time.
Can any one help me on this?
Error Logs From my application:
SQL Error: 17401, SQLState: null
Protocol violation
SQL Error: 17401, SQLState: null
Protocol violation
SQL Error: 17401, SQLState: null
Protocol violation
Rollback failed
java.sql.SQLException: Protocol violation
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160)
at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.j ava:149)
at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protoco l.java:488)
at oracle.jdbc.driver.OracleConnection.rollback(Oracl eConnection.java:1412)
at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:86)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:90)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:59)
at com.azure.spark.database.hibernate.util.HibernateU til.get(HibernateUtil.java:569)
at com.azure.spark.database.hibernate.util.HibernateS ession.get(HibernateSession.java:340)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.taskCompleted(TaskControllerComponent.java:11 54)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.onTaskEvent(TaskControllerComponent.java:1111 )
at com.azure.spark.taskcontroller.tasks.AbstractTaskC omponent.run(AbstractTaskComponent.java:354)
at java.lang.Thread.run(Thread.java:637)
Error rolling back transaction
net.sf.hibernate.TransactionException: Rollback failed with SQL exception:
at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:91)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:90)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:59)
at com.azure.spark.database.hibernate.util.HibernateU til.get(HibernateUtil.java:569)
at com.azure.spark.database.hibernate.util.HibernateS ession.get(HibernateSession.java:340)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.taskCompleted(TaskControllerComponent.java:11 54)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.onTaskEvent(TaskControllerComponent.java:1111 )
at com.azure.spark.taskcontroller.tasks.AbstractTaskC omponent.run(AbstractTaskComponent.java:354)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.sql.SQLException: Protocol violation
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160)
at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.j ava:149)
at oracle.jdbc.ttc7.TTC7Protocol.rollback(TTC7Protoco l.java:488)
at oracle.jdbc.driver.OracleConnection.rollback(Oracl eConnection.java:1412)
at net.sf.hibernate.transaction.JDBCTransaction.rollb ack(JDBCTransaction.java:86)
... 8 more
Error setting task status to completed
net.sf.hibernate.HibernateException: Error attempting to do session work
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:96)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:59)
at com.azure.spark.database.hibernate.util.HibernateU til.get(HibernateUtil.java:569)
at com.azure.spark.database.hibernate.util.HibernateS ession.get(HibernateSession.java:340)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.taskCompleted(TaskControllerComponent.java:11 54)
at com.azure.spark.taskcontroller.TaskControllerCompo nent.onTaskEvent(TaskControllerComponent.java:1111 )
at com.azure.spark.taskcontroller.tasks.AbstractTaskC omponent.run(AbstractTaskComponent.java:354)
at java.lang.Thread.run(Thread.java:637)
Caused by: net.sf.hibernate.exception.GenericJDBCException: could not load: [com.azure.spark.database.hibernate.mappings.refere nce.impl.TaskImpl#43176610]
at net.sf.hibernate.exception.ErrorCodeConverter.hand ledNonSpecificException(ErrorCodeConverter.java:90 )
at net.sf.hibernate.exception.ErrorCodeConverter.conv ert(ErrorCodeConverter.java:79)
at net.sf.hibernate.exception.JDBCExceptionHelper.con vert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.persister.AbstractEntityPersister .convert(AbstractEntityPersister.java:1332)
at net.sf.hibernate.persister.EntityPersister.load(En tityPersister.java:418)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionIm pl.java:2130)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(Se ssionImpl.java:2027)
at net.sf.hibernate.impl.SessionImpl.get(SessionImpl. java:1936)
at com.azure.spark.database.hibernate.util.HibernateU til$11.doSessionWork(HibernateUtil.java:573)
at com.azure.spark.database.hibernate.util.HibernateU til.doSessionWork(HibernateUtil.java:80)
... 7 more
Caused by: java.sql.SQLException: Protocol violation
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBE rror.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.j ava:1160)
at oracle.jdbc.ttc7.Oclose.receive(Oclose.java:133)
at oracle.jdbc.ttc7.TTC7Protocol.close(TTC7Protocol.j ava:684)
at oracle.jdbc.driver.OracleStatement.close(OracleSta tement.java:700)
at oracle.jdbc.driver.OraclePreparedStatement.private Close(OraclePreparedStatement.java:489)
at oracle.jdbc.driver.OraclePreparedStatement.close(O raclePreparedStatement.java:396)
at net.sf.hibernate.impl.BatcherImpl.closePreparedSta tement(BatcherImpl.java:273)
at net.sf.hibernate.impl.BatcherImpl.closeStatement(B atcherImpl.java:141)
at net.sf.hibernate.impl.BatcherImpl.closeQueryStatem ent(BatcherImpl.java:157)
at net.sf.hibernate.impl.BatcherImpl.closeQueryStatem ent(BatcherImpl.java:104)
at net.sf.hibernate.loader.Loader.getResultSet(Loader .java:884)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java :269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializ eNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.j ava:911)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.j ava:931)
at net.sf.hibernate.loader.EntityLoader.load(EntityLo ader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLo ader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(En tityPersister.java:415)
... 12 more
I would start by upgrading your JDBC driver, and looking for class12.jar in your classpath. I also found this link that might help: https://forums.oracle.com/message/9710491
We had same issue.
We replaced ojdbc7.jar with ojdbc8.jar and it resolved issue.
Our hibernate version was 4.x.
This is caused due to CLOB field in your database, other option is to add space or extra character to your data.
More information here https://community.oracle.com/thread/3647914

MySql throws exception when Update statement does not find a record

I'm using MySql 5.5, queries are executing via Spring Framework(JdbcTemplate) over Jboss 5.1
I'm experiencing an issue which causes an update statement to throw the following:
javax.ejb.EJBTransactionRolledbackException: PreparedStatementCallback; uncategorized SQLException for SQL [ UPDATE events SET last_update=? WHERE account_id=? ]; SQL state [HY000]; error
code [1032]; Can't find record in 'events'; nested exception is java.sql.SQLException: Can't find record in 'events
'
My question is why do I get an exception when the record is not found(it is expected behavior) and how can I prevent that from happening.
Many Thanks
Yaniv
More Details
The table has no foreign keys. it has a total of 15 fields, out of which on is an auto increment id, and 4 others are indexed. The query is `UPDATE events SET last_update=? WHERE account_id=?
Here is also the stack trace of the actual SQLException:
Caused by: java.sql.SQLException: Can't find record in 'events'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2427)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2345)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2330)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:365)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:818)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:1)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)

Exception in Hibernate 'Cannot Release Connection'?

I have used Spring DATA JPA in my application, which is wrapper over hibernate.
While interaction with database at one point I am getting expection
Caused by: org.hibernate.exception.GenericJDBCException: Cannot release connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:478)
at org.hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:429)
at org.hibernate.jdbc.ConnectionManager.afterStatement(ConnectionManager.java:304)
at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:572)
at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:307)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
connection handling in hibernate is the internal handling we don't explicitly release or close the connection.
I can't understand how to resolve this issue..
Finally I got the solution. I solved this problem by setting some additional configuration for by database.
Here is the detailed link: http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
In nutshell ("testOnBorrow”, “testOnReturn”, “testWhileIdle”) these are the parameters I played with to remove above exception.
Above exception show at some point of time our database connection object get invalidated somehow. But these setting helps us to keep check on our database connection.
Cheers :)

Categories