StatementWatcher.java 841 字节
Newer Older
T
Tom Qian 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/**
 * 
 */
package top.qianxinyao.dbconnection;

import java.sql.SQLException;
import java.sql.Statement;

/**
 * @author qianxinyao
 * @email tomqianmaple@gmail.com
 * @github https://github.com/bluemapleman
 * @date 2016年11月23日
 */
public class StatementWatcher extends Thread
{
	private Statement watchedStmt;
	public StatementWatcher(Statement watchedStmt){
		this.watchedStmt=watchedStmt;
	}
	public void run(){
		//防止还未开始
		try
		{
			Thread.sleep(10000);
		}
		catch (InterruptedException e1)
		{
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		while(true){
			try
			{
				if(this.watchedStmt.isClosed()){
					break;
				}
				else{
				    this.watchedStmt.close();
				}
			}
			catch (SQLException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}
}