?? connectionkeeper.java
字號:
package com.neu.wrm.common;
import java.sql.Connection;
import java.lang.InheritableThreadLocal;
/*
* Created on 2005-4-6
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author liuyuguang
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class ConnectionKeeper {
private static InheritableThreadLocal thread = new InheritableThreadLocal();
/**
*
* @return Returns the myConnection.
*/
public static Connection getMyConnection() throws Exception {
if (Connection.class.isInstance(thread.get()))
return (Connection) thread.get();
else {
System.out.println("返回類型不匹配");
throw new Exception("can't get connection");
}
}
/**
* @param myConnection
* The myConnection to set.
*/
public static void setMyConnection(Connection con) {
clearMyConnection();
thread.set(con);
}
public static void clearMyConnection() {
thread.set(null);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -