日期:2014-05-20 浏览次数:20781 次
public static Connection getConnection() { Connection conn = null; String driver ="oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:oracle"; String uName = "scott"; String pswd = "tiger"; try { Class.forName(driver); conn = DriverManager.getConnection(url, uName, pswd); } catch (ClassNotFoundException e) { System.out.println("类加载错误"+e.getMessage()); } catch (SQLException e) { System.out.println("连接错误"+e.getMessage()); e.printStackTrace(); } return conn; }