Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package me.justinh.kingdoms.ranks.sql;
  2.  
  3. import java.sql.*;
  4.  
  5. public class SqlConnector {
  6.  
  7. private static Connection con;
  8.  
  9. public SqlConnector(boolean status) {
  10. if(status) {
  11. try {
  12. openConnection();
  13. } catch (Exception e) {
  14. e.printStackTrace();
  15. }
  16. } else {
  17. try {
  18. con.close();
  19. } catch (Exception e) {
  20. e.printStackTrace();
  21. }
  22. }
  23.  
  24. }
  25.  
  26. public SqlConnector() {
  27.  
  28. }
  29.  
  30. public void openConnection() {
  31. try{
  32. Class.forName("com.mysql.jdbc.Driver");
  33. con = DriverManager.getConnection("jdbc:mysql://66.85.144.162/mcph598161","mcph598161","b16c3c20f1");
  34. }catch (Exception e) {
  35. e.printStackTrace();
  36. }
  37. }
  38.  
  39. public void closeConnection() {
  40. try {
  41. con.close();
  42. } catch (Exception e) {
  43. e.printStackTrace();
  44. }
  45. }
  46.  
  47. public Connection getConnection() {
  48. return con;
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement