diff --git a/src/main/java/de/butzlabben/world/util/PlayerPositions.java b/src/main/java/de/butzlabben/world/util/PlayerPositions.java index 137ee8f..e3d34ea 100644 --- a/src/main/java/de/butzlabben/world/util/PlayerPositions.java +++ b/src/main/java/de/butzlabben/world/util/PlayerPositions.java @@ -88,7 +88,7 @@ public class PlayerPositions { } } - public void checkTables() { + private void checkTables() { String tableName = PluginConfig.getTableName(); try { PreparedStatement ps = util.prepareStatement("CREATE TABLE IF NOT EXISTS " + tableName + diff --git a/src/main/java/de/butzlabben/world/util/database/DatabaseConnection.java b/src/main/java/de/butzlabben/world/util/database/DatabaseConnection.java index 9fe42e0..448c154 100644 --- a/src/main/java/de/butzlabben/world/util/database/DatabaseConnection.java +++ b/src/main/java/de/butzlabben/world/util/database/DatabaseConnection.java @@ -3,8 +3,8 @@ package de.butzlabben.world.util.database; import java.sql.*; public abstract class DatabaseConnection implements DatabaseUtil { - protected Connection connection; - protected Object lock = new Object(); + Connection connection; + final Object lock = new Object(); public void close() { synchronized (lock) { @@ -44,12 +44,4 @@ public abstract class DatabaseConnection implements DatabaseUtil { return ps.executeUpdate(); } } - - public Connection getConnection() throws SQLException { - synchronized (lock) { - if (connection == null || connection.isClosed()) - connect(); - return connection; - } - } } diff --git a/src/main/java/de/butzlabben/world/util/database/DatabaseUtil.java b/src/main/java/de/butzlabben/world/util/database/DatabaseUtil.java index 24314ef..4f64d02 100644 --- a/src/main/java/de/butzlabben/world/util/database/DatabaseUtil.java +++ b/src/main/java/de/butzlabben/world/util/database/DatabaseUtil.java @@ -1,6 +1,5 @@ package de.butzlabben.world.util.database; -import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -9,7 +8,6 @@ public interface DatabaseUtil { ResultSet executeQuery(PreparedStatement preparedStatement) throws SQLException; int executeUpdate(PreparedStatement preparedStatement) throws SQLException; - public Connection getConnection() throws SQLException; PreparedStatement prepareStatement(String sql) throws SQLException; void close(); void connect(); diff --git a/src/main/java/de/butzlabben/world/util/database/MysqlConnection.java b/src/main/java/de/butzlabben/world/util/database/MysqlConnection.java index 84bf5b0..94cd5e7 100644 --- a/src/main/java/de/butzlabben/world/util/database/MysqlConnection.java +++ b/src/main/java/de/butzlabben/world/util/database/MysqlConnection.java @@ -6,7 +6,7 @@ import java.sql.*; public class MysqlConnection extends DatabaseConnection { - public void connect(String host, String database, String port, String user, String password) { + private void connect(String host, String database, String port, String user, String password) { synchronized (lock) { try { Class.forName("com.mysql.jdbc.Driver"); diff --git a/src/main/java/de/butzlabben/world/util/database/SqliteConnection.java b/src/main/java/de/butzlabben/world/util/database/SqliteConnection.java index 87290cb..c5bc3f8 100644 --- a/src/main/java/de/butzlabben/world/util/database/SqliteConnection.java +++ b/src/main/java/de/butzlabben/world/util/database/SqliteConnection.java @@ -6,7 +6,7 @@ import java.sql.*; public class SqliteConnection extends DatabaseConnection { - public void connect(String file) { + private void connect(String file) { synchronized (lock) { try { Class.forName("com.mysql.jdbc.Driver");