Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package exercises;
- import java.sql.*;
- public class JdbcEx1 {
- static Connection conn = null;
- static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
- static String user = "labs";
- static String password = "labs";
- public JdbcEx1() {}
- public static void main (String args[]) throws SQLException {
- try{
- Class.forName("oracle.jdbc.driver.OracleDriver");
- } catch (ClassNotFoundException e){
- System.err.println(e.getMessage());
- }
- try {
- conn = DriverManager.getConnection(dbURL, user, password);
- conn.clearWarnings();
- System.out.println("Connection opened! for driver ==>Oracle 11XE");
- } catch (SQLException e) {
- System.err.println(e.getMessage());
- } finally {
- if(!conn.isClosed()) {
- conn.close();
- System.out.println("Connection Close! Oracle");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement