📄 proxooldbpoolprogrammatically.java
字号:
package common.db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.ProxoolFacade;
/**
* proxool pool
* 当前仅提供支持oracle数据库
* @author lixu
*
*/
public class ProxoolDBPoolProgrammatically extends DBPool {
private String alias;
private String url;
@Override
public Connection open() throws Exception {
// TODO Auto-generated method stub
return DriverManager.getConnection(url);
}
@Override
public void destroyPool(String reason) {
// TODO Auto-generated method stub
try
{
ProxoolFacade.killAllConnections(alias, reason, false);
}
catch(ProxoolException e)
{
e.printStackTrace(System.err);
}
}
/**
* 通过属性列表初始化连接池
* @param props
* @throws Exception
*/
public void init(Properties props) throws Exception
{
this.alias = props.getProperty(DBPool.ALIAS, "bss_db");
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
Properties info = new Properties();
info.setProperty("proxool.maximum-connection-count", props.getProperty(DBPool.MAX_CONN, "20"));
info.setProperty("proxool.house-keeping-test-sql", props.getProperty(DBPool.TEST_SQL, "select 1 from dual"));
info.setProperty("user", props.getProperty(DBPool.USER));
info.setProperty("password", props.getProperty(DBPool.PASSWORD));
String driverClass = props.getProperty(DBPool.DRIVER);
String driverUrl = props.getProperty(DBPool.URI);
String url = "proxool." + alias + ":" + driverClass + ":" + driverUrl;
this.url = "proxool." + alias;
ProxoolFacade.registerConnectionPool(url, info);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -