Register Connection Pool

Top  Previous  Next

Overview:

 

For this to work, you will need three things, a JDBC driver, your own properly configured database properties file 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

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

 

 

Snippet:

 

// NOTE: THE OBJECTFACTORY FOR REGISTERING THE CONNECTION POOL IS IN THE
// COMMONS POOL COMPONENT NOT IN THE OBJECTFACTORY OF YOUR DOMAIN MODEL.
 
import com.wickedfastsolutions.commons.pool.component.api.ObjectFactory;
import com.wickedfastsolutions.commons.pool.component.api.RegistrationException;
 
public class Application
{
    public static void main(final String[] args) throws RegistrationException
    {
        registerDatabase();
    }
    
    // binds the connection pool to the supplied jndi name
    // the jndi name must match the dataSourceName in your schema
 
    private static void registerDatabase() throws RegistrationException
    {
        com.wickedfastsolutions.commons.pool.component.api.ObjectFactory.registerConnectionPool("jdbc/catalogName""database.properties");
    }
}