📄 databasehandle.java
字号:
/* **************************************************************** *//* System Name : 億乕僞儖仌僌儖乕僾僂僄傾僾儘僕僃僋僩 * File Name : 僐儞僥儞僣偺僷僗曄姺僣乕儖(AddConst.java) * Compiler : JDK 1.5.0 * Description : 僆儔僋儖儐乕僓僷僗儚乕僪愙懕僋儔僗 * ---------------------------------------------------------------- * Modification History * Date Name Description * ----------- -------------- ----------------------------------- * 2007/11/XX Initial Release * ---------------------------------------------------------------- *//* **************************************************************** */package common;import java.sql.*;public class DatabaseHandle { private static String user = "scott"; private static String password = "tiger"; private static String urlORACLE = "jdbc:oracle:thin:@localhost:1521:ORADB"; private static String driverORACLE = "oracle.jdbc.driver.OracleDriver"; private static DatabaseHandle instance; public static DatabaseHandle getInstance(){ if (instance == null) instance = new DatabaseHandle(); return instance; } /* ********************************************************************** * 僆儔僋儖愙懕 * @param * @return Connection 僆儔僋儖愙懕 * @throws ClassNotFoundException,SQLException * @version *************************************************************************/ public static Connection getConnection(String uid,String pwd)throws ClassNotFoundException,SQLException { Connection con = null; try { Class.forName(driverORACLE); con = DriverManager.getConnection(urlORACLE, uid, pwd); } catch (ClassNotFoundException ex) { ex.printStackTrace(); throw ex; } catch (SQLException sqlex) { sqlex.printStackTrace(); throw sqlex; } return con; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -