Sunday 15 January 2012

java - Multiple Data sources for C3P0 -



java - Multiple Data sources for C3P0 -

i developing tool receives different connection parameters test values in different databases (a plugin nagios in jnrpe keeps open connection different databases). because configuration dynamic (there more databases or can removed) cannot have configuration file.

i want know if should have instance of c3p0 per database or can utilize same instance , alter url each time inquire connection?

the code @ github: https://github.com/angoca/db2-jnrpe/blob/master/src/main/java/com/github/angoca/db2_jnrpe/database/pools/c3p0/dbcp_c3p0.java

if not, how can multiple pool multiple databases dynamically?

you'll need different c3p0 datasource each jdbc url. connection pool must contain homogeneous connections: checked out connections must equivalent client's perspective. if connections multiple databases included in same pool, clients have no way of specifying or knowing db communicating with.

(if replicating, say, read-only db , want connections multiple sources live in single pool, because guaranteed equivalent client's point of view, defining custom, unpooled datasource round-robined or randomly chose replicant, , pooling datasource via c3p0's datasources factory.)

it easy dynamically create , configure c3p0 datasources. see illustration code here.

if capture dynamic config map of c3p0 property names values, there's alternative, more concise way datasource configuration.

java jdbc connection-pooling c3p0

No comments:

Post a Comment