Error accessing PooledConnection. Connection is invalid.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error accessing PooledConnection. Connection is invalid.

Eugene Dzhurinsky
I have some problems with MyBatis 3.4.1, MyBatis Guice 3.6 and PostgreSQL 9.4. For some reason sometimes I have an exception:

org.apache.ibatis.exceptions.PersistenceException Error during getting and compressing a project: {} 
### Error committing transaction.  Cause: java.sql.SQLException: Error accessing PooledConnection. Connection is invalid.
### Cause: java.sql.SQLException: Error accessing PooledConnection. Connection is invalid.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:227)
at org.apache.ibatis.session.SqlSessionManager.commit(SqlSessionManager.java:297)
at org.mybatis.guice.transactional.TransactionalMethodInterceptor.invoke(TransactionalMethodInterceptor.java:125)

My current configuration for the connection manager looks like:

           <dataSource type="POOLED">
               
<property name="driver" value="org.postgresql.Driver"/>
               
<property name="url" value="jdbc:postgresql://${JDBC.host}:${JDBC.port}/${JDBC.schema}"/>
               
<property name="username" value="${JDBC.username}"/>
               
<property name="password" value="${JDBC.password}"/>
               
<property name="poolMaximumActiveConnections" value="30"/>
               
<property name="poolMaximumIdleConnections" value="10"/>
               
<property name="poolPingEnabled" value="true"/>
               
<property name="poolPingQuery" value="select 1"/>
           
</dataSource>

What could cause this error and how do I fix it?

Thanks!

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error accessing PooledConnection. Connection is invalid.

Jose María Zaragoza
2016-09-06 12:39 GMT+02:00 jdevelop <[hidden email]>:

> I have some problems with MyBatis 3.4.1, MyBatis Guice 3.6 and PostgreSQL
> 9.4. For some reason sometimes I have an exception:
>
> org.apache.ibatis.exceptions.PersistenceException Error during getting and
> compressing a project: {}
> ### Error committing transaction.  Cause: java.sql.SQLException: Error
> accessing PooledConnection. Connection is invalid.
> ### Cause: java.sql.SQLException: Error accessing PooledConnection.
> Connection is invalid.
> at
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
> at
> org.apache.ibatis.session.defaults.DefaultSqlSession.commit(DefaultSqlSession.java:227)
> at
> org.apache.ibatis.session.SqlSessionManager.commit(SqlSessionManager.java:297)
> at
> org.mybatis.guice.transactional.TransactionalMethodInterceptor.invoke(TransactionalMethodInterceptor.java:125)
>
>
> My current configuration for the connection manager looks like:
>
>            <dataSource type="POOLED">
>                 <property name="driver" value="org.postgresql.Driver"/>
>                 <property name="url"
> value="jdbc:postgresql://${JDBC.host}:${JDBC.port}/${JDBC.schema}"/>
>                 <property name="username" value="${JDBC.username}"/>
>                 <property name="password" value="${JDBC.password}"/>
>                 <property name="poolMaximumActiveConnections" value="30"/>
>                 <property name="poolMaximumIdleConnections" value="10"/>
>                 <property name="poolPingEnabled" value="true"/>
>                 <property name="poolPingQuery" value="select 1"/>
>             </dataSource>
>
> What could cause this error and how do I fix it?
>

Hi:

Well, I'm not sure, but there is a parameter called
poolMaximumCheckoutTime, that according to MyBatis documentation

poolMaximumCheckoutTime – This is the amount of time that a Connection
can be "checked out" of the pool before it will be forcefully
returned. Default: 20000ms (i.e. 20 seconds)

I don't know if this parameter is equal to validationInterval of JDBC
Connection Pool .
I'd got an error like yours if validationInterval is set to default
time ( 20 seconds ) and the database server is down randomly.
I tested to set a lower value ( 5 seconds ) and "Connection is
invalid" error was gone.
But the root of the problem was the database link connection, so I set
validationInterval to 20 seconds again ( by performance reasons )



> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...