Module connection/util
Provides various utility functions for instantiating JDBC connection pools
initConnectionPool (props)
Factory method for creating and initializing a connection pool. If the props
argument contains a pool
property, this method returns one of the following
connection pools (provided that the necessary jar files have been placed
into the jars
directory of SqlStore):
c3p0
creates a c3p0 datasourceboneCP
creates a BoneCP datasource
If no pool
property is set, the standard connection pool is instantiated.
Example
// standard connection pool connecting to a h2 in-memory database initConnectionPool({ "url": "jdbc:h2:mem:databasename;MVCC=TRUE", "driver": "org.h2.Driver" }) // standard connection pool connecting to a MySQL database // (this needs the MySQL JDBC driver jar in the `jars` // directory of SqlStore) initConnectionPool({ "url": "jdbc:mysql://localhost/databasename", "driver": "com.mysql.jdbc.Driver", "user": "test", "password": "secret" }) // c3p0 connection pool connecting to a PostgreSQL database - for this // the PostgreSQL JDBC driver jar and the c3p0 jar files must be present // in the `jars` directory of SqlStore. // For further configuration of the pool define the appropriate properties // in the object passed as argument initConnectionPool({ "pool": "c3p0", "url": "jdbc:postgresql://localhost/databasename", "driver": "org.postgresql.Driver", "user": "test", "password": "secret", "minPoolSize": 5, "acquireIncrement": 2, "numHelperThreads": 6, "maxPoolSize": 20, "maxStatementsPerConnection": 10, }) // BoneCP connection pool connecting to an Oracle database - for this // the Oracle JDBC driver jar and the BoneCP jar files must be present // in the `jars` directory of SqlStore // For further configuration of the pool define the appropriate properties // in the object passed as argument initConnectionPool({ "pool": "boneCP", "url": "jdbc:postgresql://localhost/databasename", "driver": "org.postgresql.Driver", "user": "test", "password": "secret", "minConnectionsPerPartition": 5, "acquireIncrement": 5, "maxConnectionsPerPartition": 20, "partitionCount": 1, })
Parameters
Object | props | The connection pool properties. |
Returns
The connection pool |