Register Multiple Connection Pools

Top  Previous  Next

Overview:

 

For this to work, you will need four things, a JDBC driver, two properly configured database properties files and the wickedfastsolutions connection pool in your classpath. The wickedfastsolutions connection pool is considered part of the dependencies and are already included in the generated dist/jar files.

 

- JDBC driver (appropriate for your database)

- doc/database.properties as (transactional.properties)

- doc/database.properties as (reporting.properties)

- dist/classes.jar (most likely already on your classpath)

 

 

Snippet:

 

import com.wickedfastsolutions.commons.pool.component.api.ObjectFactory;

import com.wickedfastsolutions.commons.pool.component.api.RegistrationException;
 
import java.io.File;
 
public class Application
{
    public static void main(final String[] args) throws RegistrationException
    {
        final File transactional = new File("transactional.properties");
        final File reporting = new File("reporting.properties");
 
        ObjectFactory.registerConnectionPool("jdbc/transactional", transactional);
        ObjectFactory.registerConnectionPool("jdbc/reporting", reporting);
    }
}

 

 


NOTE: THE OBJECTFACTORY FOR REGISTERING THE CONNECTION POOL IS IN THE

COMMONS POOL COMPONENT NOT IN THE OBJECTFACTORY OF YOUR DOMAIN MODEL.