2010年4月16日 星期五

proxool 0.9.1 連線

1.下載驅動
官網
----------------------------------------------------------------------------
2. web.xml

<servlet>
  <servlet-name>ServletConfigurator</servlet-name>
  <servlet-class>org.logicalcobwebs.proxool.configuration.ServletConfigurator</servlet-class>
  <init-param>
    <param-name>xmlFile</param-name>
    <param-value>WEB-INF/proxool.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>

-------------------------------------------------------------------------------
3. proxool.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- the proxool configuration can be embedded within your own application's. Anything outside the "proxool" tag is ignored. -->
<something-else-entirely>

  <proxool>
    <alias>mysql</alias>
         <driver-url>jdbc:mysql://127.0.0.1:3306/資料庫名稱</driver-url>
         <driver-class>com.mysql.jdbc.Driver</driver-class>
         <driver-properties>
            <property name="user" value="root" />
            <property name="password" value="1234" />
        </driver-properties>
         <minimum-connection-count>1</minimum-connection-count>
         <maximum-connection-count>10</maximum-connection-count>
  </proxool>

</something-else-entirely>



----------------------------------------------------------------------------------------------
4. 程式中
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
connection = DriverManager.getConnection(proxool.mysql);
...
connection.close();
-------------------------------------------------------------------------------------------


ps. 因為我忘記加了Class.forName,搞這個搞了好幾天....

沒有留言: