日期:2014-05-20 浏览次数:20910 次
public class OracleConnection { private final static String ORACLE_URL = "jdbc:oracle:thin:@localhost:1521:orcl"; private final static String USER = "szerp"; private final static String PASSWORD = "szerp"; public static void loadDriver() throws ClassNotFoundException { Class.forName("oracle.jdbc.driver.OracleDriver"); } public static Connection getConnection() throws SQLException, ClassNotFoundException { loadDriver(); return DriverManager.getConnection(ORACLE_URL, USER, PASSWORD); } } public class Test { public static void main(String[] a) throws Exception { Connection conn = OracleConnection.getConnection(); } }