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