Configuration
... SourceForge.net Logo
 
 
 
 
Latest
The latest version of Proxool is 0.9.1
Donations
You can donate to Proxool in the usual way:
sourceforge.net
 

You can configure Proxool in lots of ways.

1. Passing a java.util.Properties object to the Driver when you request a Connection:

Properties info = new Properties();
info.setProperty("proxool.maximum-connection-count", "20");
info.setProperty("proxool.house-keeping-test-sql", "select CURRENT_DATE");
info.setProperty("user", "sa");
info.setProperty("password", "");
String alias = "test";
String driverClass = "org.hsqldb.jdbcDriver";
String driverUrl = "jdbc:hsqldb:test";
String url = "proxool." + alias + ":" + driverClass + ":" + driverUrl;
connection = DriverManager.getConnection(url, info);

 

2. Using an XML file. For instance:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- the proxool configuration can be embedded within your own application's.
Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>
  <proxool>
    <alias>xml-test</alias>
    <driver-url>jdbc:hsqldb:.</driver-url>
    <driver-class>org.hsqldb.jdbcDriver</driver-class>
    <driver-properties>
      <property name="user" value="sa"/>
      <property name="password" value=""/>
    </driver-properties>
    <maximum-connection-count>10</maximum-connection-count>
    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
  </proxool>
</something-else-entirely>

And then simply call the XML configurator (JAXPConfigurator) in your startup code:

JAXPConfigurator.configure("src/java-test/org/logicalcobwebs/proxool/configuration/test-no-ns.xml", false);
// The false means non-validating

And then, picking up connections is really easy ("xml-test" is the alias we used above)

connection = DriverManager.getConnection("proxool.xml-test");

NOTE: you need to include a JAXP compliant XML parser to use this configuration method. For instance, Crimson, or Xerces

3. Using a properties (flat text) file. For instance

jdbc-0.proxool.alias=property-test
jdbc-0.proxool.driver-url=jdbc:hsqldb:.
jdbc-0.proxool.driver-class=org.hsqldb.jdbcDriver
jdbc-0.user=sa
jdbc-0.password=
jdbc-0.proxool.maximum-connection-count=10
jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE

The first word (up to the first dot) must start with "jdbc", but it can be anything you like. Use unique names to identify each pool. Any property not starting with "jdbc" will be ignored. The properties prefixed with "proxool." will be used by Proxool while the properties that are not prefixed will be passed on to the delegate JDBC driver.

And then simply call the property configurator (PropertyConfigurator) in your startup code:

PropertyConfigurator.configure("src/java-test/org/logicalcobwebs/proxool/configuration/test.properties");

Again, picking up connections is really easy ("property-test" is the alias we used above)

connection = DriverManager.getConnection("proxool.property-test");

 

4. Programmatically. For instance

Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
Properties info = new Properties();
info.setProperty("proxool.maximum-connection-count", "10");
info.setProperty("proxool.house-keeping-test-sql", "select CURRENT_DATE");
info.setProperty("user", "sa");
info.setProperty("password", "");
String alias = "test";
String driverClass = "org.hsqldb.jdbcDriver";
String driverUrl = "jdbc:hsqldb:test";
String url = "proxool." + alias + ":" + driverClass + ":" + driverUrl;
ProxoolFacade.registerConnectionPool(url, info);

Again, picking up connections is really easy ("test" is the alias we used above)

connection = DriverManager.getConnection("proxool.test");

 

5. Using Avalon (choose this if you already use Avalon in your project). For instance:

role.config -

<role-list>
  <role
    name="org.logicalcobwebs.proxool.configuration.AvalonConfigurator"
    shorthand="proxool-config"
    default-class="org.logicalcobwebs.proxool.configuration.AvalonConfigurator"/>
</role-list>

component.config -

<component-config>
  <proxool-config>
    <proxool>
      <alias>avalon-test</alias>
      <driver-url>jdbc:hsqldb:.</driver-url>
      <driver-class>org.hsqldb.jdbcDriver</driver-class>
      <driver-properties>
        <property name="user" value="sa"/>
        <property name="password" value=""/>
      </driver-properties>
    </proxool>
  </proxool-config>
</component-config>

See AvalonConfigurator.