commited old files
This commit is contained in:
parent
fb5b1cab86
commit
89db579d3e
1 changed files with 48 additions and 0 deletions
48
src/ml/codenoodles/lmve/modules/SQLUpdateHandler.java
Normal file
48
src/ml/codenoodles/lmve/modules/SQLUpdateHandler.java
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package ml.codenoodles.lmve.modules;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import ml.codenoodles.lmve.Main;
|
||||||
|
import ml.codenoodles.lmve.other.ConsoleColor;
|
||||||
|
|
||||||
|
public class SQLUpdateHandler {
|
||||||
|
|
||||||
|
private Main main;
|
||||||
|
public SQLUpdateHandler(Main main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkDBVersion() {
|
||||||
|
Connection conn;
|
||||||
|
String path = "jdbc:sqlite:" + main.getDataFolder().getAbsolutePath() + "/" + "Players.db";
|
||||||
|
try {
|
||||||
|
conn = DriverManager.getConnection(path);
|
||||||
|
String query = "SELECT VERSION AS version FROM tblDatabaseInfo WHERE ID = 1;";
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
ResultSet rs = stmt.executeQuery(query);
|
||||||
|
rs.next();
|
||||||
|
int oldVersion = rs.getInt("version");
|
||||||
|
if(oldVersion < Main.DB_VER) {
|
||||||
|
Updater(oldVersion);
|
||||||
|
}
|
||||||
|
conn.close();
|
||||||
|
|
||||||
|
}catch(SQLException sqlEx) {
|
||||||
|
System.out.println(ConsoleColor.RED + "[LMVE]" + sqlEx.getMessage() + ConsoleColor.RESET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Updater(int oldVersion) {
|
||||||
|
for(int i = oldVersion; i > Main.DB_VER; i++) {
|
||||||
|
UpdateToVersion(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateToVersion(int Version) {
|
||||||
|
//No updates yet.
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue