Guest User

Untitled

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