Proxool 0.9.1 笔记

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>  
    <servlet>  
        <servlet-name>dbpool</servlet-name>  
        <servlet-class>  
            org.logicalcobwebs.proxool.admin.servlet.AdminServlet   
        </servlet-class>  
    </servlet>  
    <servlet-mapping>  
        <servlet-name>dbpool</servlet-name>  
        <url-pattern>/dbpool</url-pattern>  
    </servlet-mapping> 



proxool.xml
<?xml version="1.0" encoding="UTF-8"?>
<pools>
	<proxool>

		<alias>base</alias>

		<driver-url>
			jdbc:jtds:sqlserver://localhost:1433/aaa
		</driver-url>

		<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
		<driver-properties>
			<property name="user" value="sa" />
			<property name="password" value="sa" />
		</driver-properties>

		<house-keeping-sleep-time>90000</house-keeping-sleep-time>

		<simultaneous-build-throttle>130</simultaneous-build-throttle>

		<prototype-count>3</prototype-count>

		<maximum-connection-count>100</maximum-connection-count>

		<minimum-connection-count>3</minimum-connection-count>
	</proxool>
	<proxool>

		<alias>project</alias>

		<driver-url>
			jdbc:jtds:sqlserver://localhost:1433/bbb
		</driver-url>

		<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
		<driver-properties>
			<property name="user" value="sa" />
			<property name="password" value="sa" />
		</driver-properties>

		<house-keeping-sleep-time>90000</house-keeping-sleep-time>

		<simultaneous-build-throttle>130</simultaneous-build-throttle>

		<prototype-count>3</prototype-count>

		<maximum-connection-count>100</maximum-connection-count>

		<minimum-connection-count>3</minimum-connection-count>
	</proxool>
</pools>







public class PoolManager {        
    private static PoolManager instance=new PoolManager();        
    private static int activeCount = 0;        
    private final Logger logger = Logger.getLogger(getClass());        
            
    private PoolManager(){  
        try {
            Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
            logDebug("加载Proxool驱动成功");
        } catch (ClassNotFoundException e) {
            logDebug("加载Proxool驱动失败",e);
            e.printStackTrace();
            throw new RuntimeException("加载Proxool驱动失败",e);
        }
    }
    
    public static PoolManager getInstance(){
        return instance;
    }
    public Connection getConnection(String database) {        
        try{        
            //proxool驱动类        
            Connection conn = DriverManager.getConnection(database);
            logDebug("getConnection for "+database);
            System.out.println("getConnection");
           //此处的DBPool是在proxool.xml中配置的连接池别名       
//            showSnapshotInfo(database);        
            return conn;        
        }catch(Exception ex){   
            logDebug("error when get connection for "+database, ex);
            ex.printStackTrace();  
            return null;
        }        
                
    }       

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值