Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.ironfight.official;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class SQLConnection {
- private Connection connection;
- private String url, host, database, user, pass;
- public SQLConnection(String url, String host, String database, String user, String pass) {
- this.url = url;
- this.host = host;
- this.database = database;
- this.user = user;
- this.pass = pass;
- }
- public void connection() {
- if(!isConnected()) {
- try {
- connection = DriverManager.getConnection(url + host + "/" + database + user + pass);
- System.out.println("La base de donnée MySQL à bien été connecté");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public void disconnect() {
- if(isConnected()) {
- try {
- connection.close();
- System.out.println("La base de donnée MySQL à bien été fermé");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public boolean isConnected() {
- return connection != null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement