Advertisement
MrGG4ming

Untitled

Feb 6th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. package com.terrains;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class MySql {
  8.  
  9. public static Connection con;
  10.  
  11. public static void connect() {
  12. if (!isConnected()) {
  13. try {
  14. con = DriverManager.getConnection("jdbc:mysql://localhost/batt_356?autoReconnect=true", "batt_356",
  15. "ddb38916fd");
  16. System.out.println("MySql Conectado");
  17. } catch (SQLException e) {
  18. e.printStackTrace();
  19. }
  20. }
  21. }
  22.  
  23. public static void disconnect() {
  24. if (isConnected()) {
  25. try {
  26. con.close();
  27. System.out.println("MySql Desconectado");
  28. } catch (SQLException e) {
  29. e.printStackTrace();
  30. }
  31. }
  32. }
  33.  
  34. public static boolean isConnected() {
  35. return (con != null);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement