Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.japanes.lobby;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- * Created by Gio on 23/12/2016.
- */
- public class SqlConnection {
- public static Connection connection;
- public static String urlbase,host,database,user,password;
- public SqlConnection(String urlbase, String host, String database, String user, String password){
- this.urlbase=urlbase;
- this.host=host;
- this.database=database;
- this.user=user;
- this.password=password;
- }
- public void connection(){
- if(!isConnected()){
- try {
- connection = DriverManager.getConnection(urlbase+ host + "/" + database, user, password);
- System.out.println("[Sql]La connection entre le serveur et la base de donnée a été effectuée");
- }catch (SQLException e){
- e.printStackTrace();
- }
- }
- }
- public void disconnect(){
- try {
- connection.close();
- System.out.println("La base de donnée a été déconnectée.");
- }catch (SQLException e){
- e.printStackTrace();
- }
- }
- public boolean isConnected(){
- return connection!=null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement