我用proxool来做连接池,我用一个线程来实现的,如下:
/*
* Created on 2005-4-13
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.sql.*;
import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
/**
* @author LIZHIWO_WO
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
* 利用Proxool数据库连接池处理该程序!
*
*/
public class RingDown
{
//初始化构造函数
public RingDown()
{
System.out.println("<<<<<<<**************>>>>>>>>程序开始运行!");
}
public static void main(String [] args)
{ //创建一个线程处理报表程序
RingThread bill = new RingThread();
new Thread(bill).start();
}
}class RingThread implements Runnable
{
Connection con=null;
Statement stmt=null;
ResultSet rst=null;
//初始化构造函数,初始化数据库连接池。
public RingThread()
{
try
{
//读取Proxool JDBC 驱动
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
//读取配置文件proxool.properties
PropertyConfigurator.configure("proxool.properties");
System.out.println("<<<<<<<**************>>>>>>>>初始化数据库连接池完毕!");
}
catch(Exception e){}
System.out.println("<<<<<<<**************>>>>>>>>线程开始运行!");
}
//线程开始运行处--------------------------------------------------
public void run()
{
while(true)
{
try
{
String HeXuan=null;
String ID=null;
try
{
//获取一个con从连接池中
con = DriverManager.getConnection("proxool.MyTest");
}
catch(SQLException e){System.out.println("Problem getting connection"+e);}
if(con!=null)
{
System.out.println("Get A Connection");
}
else
{
System.out.println("Didn't get connection, which probably means that no Driver accepted the URL!");
}
stmt = con.createStatement();
//扫描telpushtable表是否有符合条件的处理纪录。
String SQL="select top 1 * from name ";
rst=stmt.executeQuery(SQL);
while(rst.next())
{
。
}
rst.close();
stmt.close();
con.close();
}
catch(Exception e){}
try
{
Thread.sleep(1000);
System.out.println("------------->>>>> 下一条");
}
catch(Exception e){System.out.println(e.toString());}
}
}
}
---------------------------------------------------------------------
proxool.properties如下:
jdbc-0.proxool.alias=MyTest
jdbc-0.proxool.driver-class=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc-0.proxool.driver-url=jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=MyData
jdbc-0.user=sa
jdbc-0.password=3211535
jdbc-0.proxool.maximum-connection-count=10
jdbc-0.proxool.prototype-count=4jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
jdbc-0.proxool.verbose=true
jdbc-0.proxool.statistics=10s,1m,1d
jdbc-0.proxool.statistics-log-level=DEBUG我的程序在程序运行一段时间后,出现了这样一个错误
org.logicalcobwebs.proxool.HouseKeeper sweep
警告:#0085 was active for 302515 millisecoonds and has been removed automaticaly. The Thread responsible was named 'Thread-6'.
请问,我的错误在哪里?应该如何解决?
/*
* Created on 2005-4-13
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.sql.*;
import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
/**
* @author LIZHIWO_WO
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
* 利用Proxool数据库连接池处理该程序!
*
*/
public class RingDown
{
//初始化构造函数
public RingDown()
{
System.out.println("<<<<<<<**************>>>>>>>>程序开始运行!");
}
public static void main(String [] args)
{ //创建一个线程处理报表程序
RingThread bill = new RingThread();
new Thread(bill).start();
}
}class RingThread implements Runnable
{
Connection con=null;
Statement stmt=null;
ResultSet rst=null;
//初始化构造函数,初始化数据库连接池。
public RingThread()
{
try
{
//读取Proxool JDBC 驱动
Class.forName("org.logicalcobwebs.proxool.ProxoolDriver");
//读取配置文件proxool.properties
PropertyConfigurator.configure("proxool.properties");
System.out.println("<<<<<<<**************>>>>>>>>初始化数据库连接池完毕!");
}
catch(Exception e){}
System.out.println("<<<<<<<**************>>>>>>>>线程开始运行!");
}
//线程开始运行处--------------------------------------------------
public void run()
{
while(true)
{
try
{
String HeXuan=null;
String ID=null;
try
{
//获取一个con从连接池中
con = DriverManager.getConnection("proxool.MyTest");
}
catch(SQLException e){System.out.println("Problem getting connection"+e);}
if(con!=null)
{
System.out.println("Get A Connection");
}
else
{
System.out.println("Didn't get connection, which probably means that no Driver accepted the URL!");
}
stmt = con.createStatement();
//扫描telpushtable表是否有符合条件的处理纪录。
String SQL="select top 1 * from name ";
rst=stmt.executeQuery(SQL);
while(rst.next())
{
。
}
rst.close();
stmt.close();
con.close();
}
catch(Exception e){}
try
{
Thread.sleep(1000);
System.out.println("------------->>>>> 下一条");
}
catch(Exception e){System.out.println(e.toString());}
}
}
}
---------------------------------------------------------------------
proxool.properties如下:
jdbc-0.proxool.alias=MyTest
jdbc-0.proxool.driver-class=com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc-0.proxool.driver-url=jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=MyData
jdbc-0.user=sa
jdbc-0.password=3211535
jdbc-0.proxool.maximum-connection-count=10
jdbc-0.proxool.prototype-count=4jdbc-0.proxool.house-keeping-test-sql=select CURRENT_DATE
jdbc-0.proxool.verbose=true
jdbc-0.proxool.statistics=10s,1m,1d
jdbc-0.proxool.statistics-log-level=DEBUG我的程序在程序运行一段时间后,出现了这样一个错误
org.logicalcobwebs.proxool.HouseKeeper sweep
警告:#0085 was active for 302515 millisecoonds and has been removed automaticaly. The Thread responsible was named 'Thread-6'.
请问,我的错误在哪里?应该如何解决?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货