Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class MySQL {
- private static Connection connection;
- private static String url_base = "jdbc:mysql://", host = "minecraft23.omgserv.com/minecraft_464",
- username = "minecraft_464", passeword = "tutobdd";
- public static Connection getConnection(){
- return connection;
- }
- public static boolean isConnected(){
- try {
- if((connection == null) || (connection.isClosed())){
- return false;
- }else{
- return true;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- public static void connection(){
- if(!isConnected()){
- try {
- connection = DriverManager.getConnection(url_base+host, username, passeword);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void deconnection(){
- if(isConnected()){
- try {
- connection.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment