Advertisement
Guest User

Untitled

a guest
Mar 29th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. package exercises;
  2.  
  3. import java.sql.*;
  4.  
  5. public class JdbcEx1 {
  6. static Connection conn = null;
  7. static String dbURL = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
  8. static String user = "labs";
  9. static String password = "labs";
  10.  
  11. public JdbcEx1() {}
  12.  
  13. public static void main (String args[]) throws SQLException {
  14.  
  15. try{
  16. Class.forName("oracle.jdbc.driver.OracleDriver");
  17. } catch (ClassNotFoundException e){
  18. System.err.println(e.getMessage());
  19. }
  20.  
  21. try {
  22. conn = DriverManager.getConnection(dbURL, user, password);
  23. conn.clearWarnings();
  24. System.out.println("Connection opened! for driver ==>Oracle 11XE");
  25. } catch (SQLException e) {
  26. System.err.println(e.getMessage());
  27. } finally {
  28. if(!conn.isClosed()) {
  29. conn.close();
  30. System.out.println("Connection Close! Oracle");
  31. }
  32. }
  33.  
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement