Could not inspect JDBC autocommit mode
Asked Answered
H

2

9

We are using spring data jpa, and at one place we have injected entity manager.
For all other functionalities we are using jpa-repository but for one functionality we are using injected entity manager. This works fine for some time after application is started but starts giving below error. It seems after some time entity-manager drops the database connection. Not able to replicate this. Is there any time out setting in entity manager after which it drops DB connection.

PersistenceException:

org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not inspect JDBC autocommit mode   at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)     at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)     at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458)
Heinrick answered 20/11, 2017 at 11:2 Comment(0)
G
7

There is nothing like this in the entity manager itself. But your database might close connections after some time, especially when they are idle, or do a lot of work (database can have a quota on how much CPU time a connection or a transaction may use).

Your connection pool is another possible source of such surprises.

The interesting question is: why does it only happen on the entity manager you use directly. One possible reason is that you are not properly releasing the connections. This might make the connection pool consider them stale and closing them after some timeout.

In order to debug this, I would start by inspecting your connection pool configuration and activating logging for it so you can see when connections are handed out when they get returned and any other special events the pool might trigger.

Griffey answered 21/11, 2017 at 7:18 Comment(3)
Thanks a lot. I will debug the connection pool settings. Lets see what I get.. Thanks again.Heinrick
@Pandy did you ever figure this out? Seeing the same thingYelena
Yes, we figured out. We were not releasing/closing connections properly. Thanks.Heinrick
O
0

Maybe multiple instances of an application has been deployed on server/servers and autocommit is not configured on one of them!

Outwardly answered 8/1 at 9:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.