public class DBConnection { static Connection con = null; public DBConnection() { } public static Connection getConnection() throws SQLException ///public static void main(String[] args) throws ClassNotFoundException, SQLException { String url = "jdbc:oracle:thin:@localhost:1521:XE"; String uname = "system"; String pwd = "password"; try { //REGISTER DRIVER Class.forName("oracle.jdbc.driver.OracleDriver"); System.out.println("Driver registered successfully.."); System.out.println(); //ESTABLISH CONNECTION con = DriverManager.getConnection(url, uname, pwd); System.out.println("Connection established successfully.."); System.out.println(); } catch(Exception e) { e.printStackTrace(); } return con; } public void closeAll() { try { con.close(); } catch (SQLException e) { e.printStackTrace(); } } }
oracle.jdbc.driver.OracleDriver
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)