driver=net.sourceforge.jtds.jdbc.Driver url=jdbc:jtds:sqlserver://127.0.0.1:1433/data user=sa pwd=sa type=sqlserver //数据库类型 pool=1 //是否使用连接池 1 使用 max_wait=3 //连接池已满时,最大等待时间 ,单位 s #timeout ,wait time when max active , unit s max_active=20 //最大活动连接数,用这个来控制最大并发数 min_free=3 //连接池中最小空闲连接数 max_free=20 //连接池中最大空闲连接数,默认=max_active check_sql=0select getdate() //验证连接是否有效, clear_time=2 //清理空闲连接 #clear_time,remove the old connection,unit min
还可以用动态代理的方式实现连接池
2.
动态代理实现
class ConnectionWrapper implements InvocationHandler {
private final static String CLOSE_METHOD_NAME = "close". public Connection connection = null. private Connection m_originConnection = null.