李敏  
          日歷
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345
          統(tǒng)計
          • 隨筆 - 1
          • 文章 - 40
          • 評論 - 4
          • 引用 - 0

          導航

          常用鏈接

          留言簿(1)

          文章分類

          文章檔案

          相冊

          收藏夾

          它山之石

          聚賢莊

          搜索

          •  

          最新評論

           
          首先是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.
              
          -->
          <proxool>
              
          <alias>sqlserver-test</alias>
              
          <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver
              
          </driver-class>
              
          <driver-url>
                  jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=test
              
          </driver-url>
              
          <driver-properties>
                  
          <property name="user" value="sa" />
                  
          <property name="password" value="limin" />
              
          </driver-properties>
              
          <house-keeping-sleep-time>40000</house-keeping-sleep-time>
              
          <house-keeping-test-sql>select CURRENT_DATE
              
          </house-keeping-test-sql>
              
          <maximum-connection-count>10</maximum-connection-count>
              
          <minimum-connection-count>3</minimum-connection-count>
              
          <maximum-connection-lifetime>18000000
              
          </maximum-connection-lifetime> <!-- 5 hours -->
              
          <simultaneous-build-throttle>5</simultaneous-build-throttle>
              
          <recently-started-threshold>40000</recently-started-threshold>
              
          <overload-without-refusal-lifetime>50000
              
          </overload-without-refusal-lifetime>
              
          <maximum-active-time>60000</maximum-active-time>
              
          <verbose>true</verbose>
              
          <trace>true</trace>
              
          <fatal-sql-exception>ORA-1234</fatal-sql-exception>
              
          <prototype-count>2</prototype-count>
          </proxool>


          以下是代碼片段,由于測試程序使用到了DataSource作為數(shù)據(jù)庫的連接,所以沒有采用官方文檔上使用的DriverManager.getConnection(..)來直接獲得Connection

          try {
                      InputStreamReader in 
          = new InputStreamReader(getClass()
                              .getResourceAsStream(
          "/proxool.xml"));

                      JAXPConfigurator.configure(in, 
          false);

                      DataSource pooled 
          = new ProxoolDataSource("sqlserver-test");

                      UserDAO userDAO 
          = new UserDAO();

                      userDAO.setDataSource(pooled);

                      User user 
          = userDAO.find(new Integer(1));

                      System.out.println(user.getId() 
          + " " + user.getName() + " "
                              
          + user.getAge());

                  }
           catch (Exception e) {
                      
          // TODO Auto-generated catch block
                      e.printStackTrace();
                  }


          posted on 2009-02-26 20:01 李敏 閱讀(373) 評論(0)  編輯  收藏 所屬分類: 應用配置
           
          Copyright © 李敏 Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 资兴市| 本溪市| 桂林市| 石柱| 重庆市| 大连市| 阆中市| 乌海市| 许昌市| 青川县| 惠水县| 大关县| 巴塘县| 山阳县| 昌图县| 浑源县| 赣榆县| 松阳县| 喀喇| 永善县| 莱芜市| 内乡县| 成安县| 乐东| 驻马店市| 淳安县| 麦盖提县| 湖南省| 永登县| 会昌县| 万盛区| 莎车县| 余江县| 清新县| 霸州市| 平遥县| 永年县| 克什克腾旗| 万全县| 永清县| 化隆|