Guest User

Untitled

a guest
Sep 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package Classes;
  6.  
  7. import java.sql.DriverManager;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.sql.Statement;
  11.  
  12. /**
  13. *
  14. * @author Kevin
  15. */
  16. public class Connection {
  17. private java.sql.Connection conn = null;
  18.  
  19. public Connection() throws ClassNotFoundException, SQLException {
  20. Class.forName("com.mysql.jdbc.Driver");
  21.  
  22. conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/clinicas", "root", "root");
  23. }
  24.  
  25. public java.sql.Connection getConnection() {
  26. return conn;
  27. }
  28.  
  29. public void close(ResultSet rs) throws SQLException {
  30. if (rs != null) {
  31. rs.close();
  32. }
  33. }
  34.  
  35. public void close(Statement stmt) throws SQLException {
  36. if (stmt != null) {
  37. stmt.close();
  38. }
  39. }
  40.  
  41. public void destroy() throws SQLException {
  42. if (conn != null) {
  43. conn.close();
  44. }
  45. }
  46. }
Add Comment
Please, Sign In to add comment