Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.terrains;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySql {
- public static Connection con;
- public static void connect() {
- if (!isConnected()) {
- try {
- con = DriverManager.getConnection("jdbc:mysql://localhost/batt_356?autoReconnect=true", "batt_356",
- "ddb38916fd");
- System.out.println("MySql Conectado");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if (isConnected()) {
- try {
- con.close();
- System.out.println("MySql Desconectado");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected() {
- return (con != null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement