?? dbtool.java
字號:
package com.pansky.dcc.core;
import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.Connection;
import java.util.ResourceBundle;
import java.util.Properties;
/**
* Created by IntelliJ IDEA.
* User: 周宇
* Date: 2005-6-30
* Time: 14:29:06
* To change this template use File | Settings | File Templates.
*/
public class DbTool {
/**
* CADbTools 構(gòu)造子注解。
*/
public DbTool() {
super();
}
/**
* 斷開數(shù)據(jù)庫連接。
* 創(chuàng)建日期:(01-1-10 22:13:23)
*/
public static void disConnect(Connection _con) {
try {
if (_con != null && !_con.isClosed()) {
_con.close();
_con = null;
}
} catch (SQLException sqe) {
try {
_con.rollback();
_con.close();
_con = null;
} catch (Exception e) {
}
}
}
/**
* 輸出SQL錯誤詳細(xì)信息。
* 創(chuàng)建日期:(01-1-10 22:13:23)
*/
public static void printExceptions(SQLException sqe) {
while (sqe != null) {
sqe = sqe.getNextException();
}
}
/**
* 建立數(shù)據(jù)庫連接。
* 創(chuàng)建日期:(00-12-10 21:27:34)
*/
public static Connection getConnectionLink1() {
try {
//獲取數(shù)據(jù)用戶名、密碼、URL
Connection _con = null;
ResourceBundle bundle = ResourceBundle.getBundle("DCC");
Properties pros = System.getProperties();
pros.put("user", bundle.getString("LINK1_USER"));
pros.put("password", bundle.getString("LINK1_PASSWORD"));
Class.forName(bundle.getString("LINK1_CLASS")).newInstance();
_con = DriverManager.getConnection(bundle.getString("LINK1_URL"), pros);
_con.setAutoCommit(false);
System.out.println("使用數(shù)據(jù)庫連接-Normal-link1!!");
return _con;
} catch (SQLException sqe) {
System.out.println("Occur in EBDbTools::GetDBConnection()");
} catch (Exception e) {
System.out.println("Occur in EBDbTools::GetDBConnection()");
}
return null;
}
/**
* 建立數(shù)據(jù)庫連接。
* 創(chuàng)建日期:(00-12-10 21:27:34)
*/
public static Connection getConnectionLink2() {
try {
//獲取數(shù)據(jù)用戶名、密碼、URL
Connection _con = null;
ResourceBundle bundle = ResourceBundle.getBundle("DCC");
Properties pros = System.getProperties();
pros.put("user", bundle.getString("LINK2_USER"));
pros.put("password", bundle.getString("LINK2_PASSWORD"));
Class.forName(bundle.getString("LINK2_CLASS")).newInstance();
_con = DriverManager.getConnection(bundle.getString("LINK2_URL"), pros);
_con.setAutoCommit(false);
System.out.println("使用數(shù)據(jù)庫連接-Normal-link2!!");
return _con;
} catch (SQLException sqe) {
System.out.println("Occur in EBDbTools::GetDBConnection()");
} catch (Exception e) {
System.out.println("Occur in EBDbTools::GetDBConnection()");
}
return null;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -