ConnectionPool myPool = ConnectionPool.getInstance();//得到链接池实例
Connection conn=myPool.getConnection(3000);//返回一个链接,设置3秒钟超时
PreparedStatement pstmt = conn.prepareStatement(strSQL);
ResultSet rs = pstmt.executeQuery();
Connection conn=myPool.getConnection(3000);//返回一个链接,设置3秒钟超时
PreparedStatement pstmt = conn.prepareStatement(strSQL);
ResultSet rs = pstmt.executeQuery();
classpath怎么加?
我已经做好了,可是请问这样做有什么好处呢?
<%
ConnectionPool myPool = ConnectionPool.getInstance();
//得到链接池实例
Connection conn=myPool.getConnection(3000);
//返回一个链接,设置3秒钟超时
//PreparedStatement pstmt = conn.prepareStatement();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from table");
out.println("<table>");
while(rs.next()){
String gys=rs.getString(1);
String name=rs.getString(2);
out.println("<tr><td>"+gys+"</td><td>"+name+"</td></tr>");
}
out.println("</table>");
%>
全局可以调用该链接,有效的程序不会每次都去建立链接
用完就释放链接,可以用pool进行对链接管理
try
{
maxConn = Integer.parseInt("100");
}
类自己设置了100个最大连接
你怎么设置5个的?
是不是我的pool的问题?
freeConnection方法返回给连接池
不然pool怎么知道哪个连接没有使用
freeConnection方法返回给连接池
不然pool怎么知道哪个连接没有使用
你能谈谈还应该注意什么吗?
比如这个是不是很好呀?