1

i am using mysql in scala with play 2.2 and want to create a connection pool. I am recently find myself unable to get the code of creating connection pool. help...

4
  • FYI commons.apache.org/proper/commons-dbcp Commented Oct 12, 2013 at 9:55
  • 1
    To add to om-nom-nom's comment, mchange.com/projects/c3p0 is another viable option. PS, generally on SO you should at least show your past efforts/research and aim for a more specific question than "how do I do X" Commented Oct 12, 2013 at 13:26
  • 2
    Play already has connection pooling. You can get a connection with play.api.db.DB withConnection or withTransaction. Commented Oct 12, 2013 at 22:27
  • @IvanMeredith perhaps, that is the best answer. Dare to post it below? Commented Oct 13, 2013 at 11:56

1 Answer 1

2

As Ivan Meredith said, play already comes with a connection pool, (bonecp by default), so if you configure database access as described in the play docs (http://www.playframework.com/documentation/2.2.x/ScalaDatabase) the connections from withConnection or withTransaction will come from the connection pool.

If you want to fine-tune the connection pool almost everything seems to be supported in the config but I cannot find any docs on it so you might have to dive into the sources to find the configuration file property names.

Default configuration in Play 2.2 creates 1 partition with 5-30 connections.

https://github.com/playframework/playframework/blob/master/framework/src/play-jdbc/src/main/scala/play/api/db/DB.scala

Sign up to request clarification or add additional context in comments.

1 Comment

Actually, i am executing about 16 queries simultaneously via actors on mysql in play. and The problem i am facing is that TIMEOUT ERROR of mysql. i increased the maxconnections quite above than the number of queries to be executed But it still comes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.