This commit is contained in:
boy0001 2015-02-20 17:34:19 +11:00
parent dea6e84407
commit 0d382ac9c3
215 changed files with 4930 additions and 6474 deletions

View file

@ -18,7 +18,6 @@
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.database;
import java.io.File;
@ -38,10 +37,9 @@ import com.intellectualcrafters.plot.PlotSquared;
* @author tips48
*/
public class SQLite extends Database {
private final String dbLocation;
private Connection connection;
/**
* Creates a new SQLite instance
*
@ -52,7 +50,7 @@ public class SQLite extends Database {
super(plotsquared);
this.dbLocation = dbLocation;
}
@Override
public Connection openConnection() throws SQLException, ClassNotFoundException {
if (checkConnection()) {
@ -73,17 +71,17 @@ public class SQLite extends Database {
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
return this.connection;
}
@Override
public boolean checkConnection() throws SQLException {
return (this.connection != null) && !this.connection.isClosed();
}
@Override
public Connection getConnection() {
return this.connection;
}
@Override
public boolean closeConnection() throws SQLException {
if (this.connection == null) {
@ -92,26 +90,22 @@ public class SQLite extends Database {
this.connection.close();
return true;
}
@Override
public ResultSet querySQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
final Statement statement = this.connection.createStatement();
return statement.executeQuery(query);
}
@Override
public int updateSQL(final String query) throws SQLException, ClassNotFoundException {
if (checkConnection()) {
openConnection();
}
final Statement statement = this.connection.createStatement();
return statement.executeUpdate(query);
}
}