?? dbpool.java
字號:
package com.wireless.sms.ismp.global;
import java.sql.Connection;
import java.sql.SQLException;
import com.wireless.sms.pub.db.ConnectionPool;
public class DBPool {
/**
* 數據庫連接池對象
*/
public static ConnectionPool POOL = null;
/**
* 取得數據庫連接
* @return Connection
*/
public static Connection getConnection() {
Connection conn = null;
try {
conn = POOL.getConnection();
}
catch (Exception e) {
LoggerConstant.sql_log.error(e.getMessage());
}
return conn;
}
/**
* 關閉數據庫連接
* @param conn Connection
*/
public static void closeConnection(Connection conn) {
if (conn != null) {
try {
conn.close();
}
catch (SQLException ex) {
ex.printStackTrace();
}
conn = null;
}
}
public static void main(String[] args) throws Exception {
Connection conn = null;
try {
// DBPool cc = new DBPool();
conn = DBPool.getConnection();
System.out.println(conn);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
conn.close();
conn = null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -