proxool连接池情况下rowset的使用
来源:互联网 发布:灵创软件 编辑:程序博客网 时间:2024/04/27 22:02
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import java.util.logging.Logger;
import javax.sql.rowset.CachedRowSet;
import com.sun.rowset.CachedRowSetImpl;
public class RowSetFactory
{
private static Logger logger=Logger.getLogger(RowSetFactory.class.getName());
static
{
try
{
//1)非连接池情况下,用这个
//Class.forName("com.mysql.jdbc.Driver");
//2)proxool连接池
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
}catch(Exception e)
{
logger.severe(e.getLocalizedMessage());
}
}
public static CachedRowSetImpl getRowSet()
{
try
{
//1)非连接池情况下,用这个
//connection不能够释放
CachedRowSetImpl rowSet=new CachedRowSetImpl();
rowSet.setUrl("jdbc:mysql://172.18.6.7:3306/wapchannel?useUnicode=true&characterEncoding=gb2312");
rowSet.setUsername("root");
rowSet.setPassword("");
//2)proxool连接池情况下,用这个
//用这个方法,默认的15个connectionCount很快就用完了
//rowSet.setUrl("proxool.test:com.mysql.jdbc.Driver:jdbc:mysql://172.18.6.7:3306/wapchannel?user=root&password=;&useUnicode=true&characterEncoding=gb2312");
rowSet.setCommand("select Fshortening,Ftitle,Fparent where Fen_topic=''");
rowSet.execute();
return rowSet;
}
catch(Exception e)
{
logger.severe("error happen when connect to the database 16.27");
return null;
}
}
/**
* 正确的使用方法
* @param sql
* @return
*/
public static CachedRowSet query(String sql){
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
CachedRowSetImpl rs= new CachedRowSetImpl();
String url = "proxool.test:com.mysql.jdbc.Driver:jdbc:mysql://172.23.2.3:3306/wapchannel?user=root&password=;&useUnicode=true&characterEncoding=gb2312";
Properties info= new Properties();
info.setProperty("proxool.maximum-connection-count", "300");
conn=DriverManager.getConnection(url,info);
stmt = conn.createStatement();
rset = stmt.executeQuery(sql);
rs.populate(rset);
return rs;
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null)
stmt.close();
} catch (Exception e) {
}
try {
conn.close();
} catch (Exception e) {
}
conn = null;
stmt = null;
rset = null;
}
return null;
}
}
- proxool连接池情况下rowset的使用
- proxool连接池情况下rowset的使用
- proxool连接池情况下rowset的使用
- proxool连接池的使用
- Tomcat 6下配置使用Proxool的JNDI 连接池
- 监控Proxool连接池的活动连接变化情况
- spring下的proxool连接池配置
- 使用Proxool连接池
- Proxool连接池的使用心得
- proxool连接池的使用和监控
- Proxool连接池的使用心得
- Proxool连接池的使用心得
- Proxool 连接池的配置使用
- 使用连接池(proxool)的步骤
- spring下,druid,c3p0,proxool,dbcp四个数据连接池的使用和配置
- 使用proxool连接池 ,连接没有关闭的原因
- ibatis使用proxool连接池
- 使用proxool连接池技术
- Windows rootkits in 2005
- Windows服务器不支持CHAP原因猜测
- 自然奇景——雨后彩虹
- 我的原子弹式的开发工作
- 人工神经网络学习笔记
- proxool连接池情况下rowset的使用
- 学习SQL Server 第一天对SQL Server的操作遇到的一些问题和对存储过程的创建和用ASP.net(C#)调用的学习体会!
- BLENDER项目工作日志11
- 强冷空气过境洛阳形成奇特景象
- 智能手机OS版图重新划分
- 宣言
- 巨坑——人类伟大的杰作
- 不要再犹豫!
- MySQL 4.1的编码问题