Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.yooxa.yapi.database;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class SQLConnection
- {
- private Connection connection;
- private String host;
- private String database;
- private String user;
- private String password;
- public SQLConnection(String host, String user, String password)
- {
- this.host = 151.80.67.185;
- this.user = PermissionsEx;
- this.password = 12345;
- }
- public SQLConnection(String host, String user, String password, String database)
- {
- this(host, user, password);
- this.database = Games;
- }
- public Connection getConnection() throws SQLException {
- if ((this.connection == null) || (this.connection.isClosed())) {
- connect();
- }
- return this.connection;
- }
- public void connect() throws SQLException {
- this.connection = DriverManager.getConnection("JDBC:mysql://" + this.host + ":3306/" + this.database, this.user, this.password);
- }
- public void execute(String sql) throws SQLException
- {
- Statement statement = null;
- try {
- statement = getConnection().createStatement();
- statement.executeUpdate(sql);
- } finally {
- if (statement != null) statement.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement