RejectedSoftware Forums

Sign up

mysql-native ConnectionPool

I was wondering if somebody could give me an example of how the
connectionpool stuff works. I can't dicern from the source how the
connections get added to the pool and grabbed for use.

Thanks!

Re: mysql-native ConnectionPool

On Sat, 2 Nov 2013 11:42:20 -0400, Shammah Chancellor wrote:

I was wondering if somebody could give me an example of how the
connectionpool stuff works. I can't dicern from the source how the
connections get added to the pool and grabbed for use.

Thanks!

Basically, you just have to create a connection pool and call lock() to get a connection each time a transaction is made:

MysqlDB mdb = new MysqlDB(connection_string);
Connection c = mdb.lockConnection();
writefln("Server caps: %b", c.serverCapabilities);

AFAIK, there may be some issues when per-connection states are involved (those need to be reset manually for each call to lock()).

Re: mysql-native ConnectionPool

On 2013-11-03 13:13:59 +0000, Sönke Ludwig said:

MysqlDB mdb = new MysqlDB(connection_string);

Connection c = mdb.lockConnection();

writefln("Server caps: %b", c.serverCapabilities);

Do you need to cache mdb somewhere, or do you just create that each
time safely?

Re: mysql-native ConnectionPool

Am 25.11.2013 13:23, schrieb Shammah Chancellor:

On 2013-11-03 13:13:59 +0000, Sönke Ludwig said:

MysqlDB mdb = new MysqlDB(connection_string);

Connection c = mdb.lockConnection();

writefln("Server caps: %b", c.serverCapabilities);

Do you need to cache mdb somewhere, or do you just create that each time
safely?

It should be cached somewhere in a thread local variable so that it can
be shared among different tasks and the connection pool can do its work.