Guest User

Untitled

a guest
Jul 20th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package com.tukangjava.tutorial;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7.  
  8. public class DatabaseAccess {
  9. Connection connection = null;
  10.  
  11. public void connect() throws SQLException
  12. {
  13. String DRIVER = "oracle.jdbc.driver.OracleDriver";
  14. String URL = "jdbc:oracle:thin:@127.0.0.1:1521:xe";
  15. String UserName = "daniel";
  16. String Password = "daniel";
  17. try
  18. {
  19. Class.forName(DRIVER);
  20. }
  21. catch (ClassNotFoundException e)
  22. {
  23. e.printStackTrace();
  24. }
  25. try
  26. {
  27. connection = DriverManager.getConnection(URL,UserName,Password);
  28. }
  29. catch (SQLException e)
  30. {
  31. e.printStackTrace();
  32. }
  33. }
  34. public void disconnect() throws SQLException
  35. {
  36. connection.close();
  37. }
  38. }
Add Comment
Please, Sign In to add comment