Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Connection con;
- public static void connect(String host, String port, String database, String username, String password)
- {
- if (!isConnected()) {
- try
- {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- System.out.println("nxtKevu MYSQL connected");
- }
- catch (SQLException e)
- {
- System.out.println("nxtKevu MYSQL FAILED");
- e.printStackTrace();
- }
- }
- }
- public static void disconnect()
- {
- if (isConnected()) {
- try
- {
- con.close();
- System.out.println("nxtKevu MYSQL disconnected");
- }
- catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected()
- {
- return con != null;
- }
- public static Connection getCon()
- {
- return con;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement