Advertisement
koalasuccess

blah

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