No Free Connections

188 views
Skip to first unread message

Josh Kamau

unread,
Jan 2, 2012, 10:24:26 AM1/2/12
to eb...@googlegroups.com
Hi Guys. Am getting the error below. Yet am the only one connected to the database because its on my developer machine. Could ebean be failing to close connections?

regards.
josh.


java.sql.SQLException: Unsuccessfully waited [1000] millis for a connection to be returned. No connections are free. You need to Increase the max connections of [20] or look for a connection pool leak using datasource.xxx.capturestacktrace=true
at com.avaje.ebeaninternal.server.lib.sql.PooledConnectionQueue._getPooledConnectionWaitLoop(PooledConnectionQueue.java:329)
at com.avaje.ebeaninternal.server.lib.sql.PooledConnectionQueue._getPooledConnection(PooledConnectionQueue.java:307)
at com.avaje.ebeaninternal.server.lib.sql.PooledConnectionQueue.getPooledConnection(PooledConnectionQueue.java:247)
at com.avaje.ebeaninternal.server.lib.sql.DataSourcePool.getPooledConnection(DataSourcePool.java:642)
at com.avaje.ebeaninternal.server.lib.sql.DataSourcePool.getConnection(DataSourcePool.java:630)
at com.avaje.ebeaninternal.server.transaction.TransactionManager.createQueryTransaction(TransactionManager.java:346)
at com.avaje.ebeaninternal.server.core.DefaultServer.createQueryTransaction(DefaultServer.java:2090)
at com.avaje.ebeaninternal.server.core.OrmQueryRequest.initTransIfRequired(OrmQueryRequest.java:212)
at com.avaje.ebeaninternal.server.core.DefaultServer.findRowCountWithCopy(DefaultServer.java:1371)
at com.avaje.ebeaninternal.server.core.DefaultServer.findRowCount(DefaultServer.java:1364)
at com.avaje.ebeaninternal.server.querydefn.DefaultOrmQuery.findRowCount(DefaultOrmQuery.java:933)

edge

unread,
Jan 2, 2012, 10:55:20 AM1/2/12
to Ebean ORM
things to check....
1) Are not keeping transactions open? - transactions obviously hold a
connection until they are completed
2) Are you using a connection pool?
3) Can you reproduce this in a small test case?
4) Can you post some code or a test case that demonstrates the
problem?

Eddie

Josh Kamau

unread,
Jan 2, 2012, 11:16:44 AM1/2/12
to eb...@googlegroups.com
Thanks Edge;;

I noted the problem was in this code:
        for(Expression expr: expressionList){
            logger.info("Adding expression to junction: {}", expr);
            q.where().disjunction().add(expr);
        }

I changed it to this

Junction junction = q.where().disjunction();
        for(Expression expr: expressionList){
            logger.info("Adding expression to junction: {}", expr);
            junction.disjunction().add(expr);
        }

and the error disappeared.

Am Still tuning the query to get the desired results.

Josh.

edge

unread,
Jan 3, 2012, 4:33:54 AM1/3/12
to Ebean ORM
hmmm probably several queries were being generated and held
simultaneously open to produce the result hence the connection problem
It would be interesting to see why Ebean decided to create a separate
query for each OR - (I guessing that was the problem) since they can
be combined into one but detecting something like that can be very
tricky

Josh Kamau

unread,
Jan 3, 2012, 5:47:06 AM1/3/12
to eb...@googlegroups.com
Edge;

Something else ;

The code was executed with each 'Keypress' to initiate a search based on what the user has typed so far. May be the frequency with which the code was called contributed to the problem. Ebean was forced to open another connection to handle a request because the request came before the previous one is handled. In short, the problem was more on my code than ebean. I have made the relevant design changes.

Regards.
Josh.
Reply all
Reply to author
Forward
0 new messages