若使用Proxool Connection Pool發生此錯誤,代表找不到資料庫的驅動程式,須檢查設定檔有關資料庫驅動程式參數是否設定正確。

若找不到驅動程式,則會出現[org.logicalcobwebs.proxool.ProxoolException: Definition did not contain driver]錯誤

使用Datasource的設定檔範例,請注意紅字部分位置是否設定正確

 

一、Self-deployed configuration

<proxool>
<alias>jndi-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>
<jndi-name>/datasources/UserDB</jndi-name>
<jndi-java.naming.factory.initial>com.caucho.naming.InitialContextFactoryImpl</jndi-java.naming.factory.initial>
<jndi-java.naming.provider.url>localhost:1099</jndi-java.naming.provider.url>
</proxool>

二、Configuration example for Tomcat

<context>
<Resource
name="jdbc/mydatasource"
auth="Container"
type="javax.sql.DataSource"
factory="org.logicalcobwebs.proxool.ProxoolDataSource"
proxool.alias="hrs"
user="joe"
password="******"
delegateProperties="foo=bar"
proxool.driver-url="jdbc:oracle:thin:@127.0.0.1:1521:DB"
proxool.driver-class="oracle.jdbc.driver.OracleDriver"/>
</context>

 

使用一般JDBC連線的設定,請注意紅字部分位置是否設定正確

 

一、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);

 

二、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>

 

三、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

四、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);

五、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>

 

Proxool設定方法資料來源:

http://proxool.sourceforge.net/configure.html

http://proxool.sourceforge.net/datasource.html

http://proxool.sourceforge.net/properties.html

 

 

arrow
arrow
    文章標籤
    proxool
    全站熱搜

    K 發表在 痞客邦 留言(0) 人氣()