= Statement type updates
This commit is contained in:
@@ -87,7 +87,8 @@ public class DatabaseDriver
|
|||||||
private void UpdateKey(String key, String value)
|
private void UpdateKey(String key, String value)
|
||||||
{
|
{
|
||||||
String command = "UPDATE " + globalTableName + " SET " + globalValueName + " = ? WHERE " + globalKeyName + " = ?;";
|
String command = "UPDATE " + globalTableName + " SET " + globalValueName + " = ? WHERE " + globalKeyName + " = ?;";
|
||||||
driver.ExecuteStatement(command, new String[] { key, value });
|
boolean status = driver.ExecuteStatement(command, new String[] { key, value });
|
||||||
|
GlobalLog.Log(LogFilter.Database, "UpdateKey status: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Protoype updating for seeing if a key exists
|
// Protoype updating for seeing if a key exists
|
||||||
@@ -111,7 +112,8 @@ public class DatabaseDriver
|
|||||||
private void CreateKey(String key, String value)
|
private void CreateKey(String key, String value)
|
||||||
{
|
{
|
||||||
String command = "INSERT INTO " + globalTableName + " (GlobalKey, GlobalValue) VALUES (?, ?);";
|
String command = "INSERT INTO " + globalTableName + " (GlobalKey, GlobalValue) VALUES (?, ?);";
|
||||||
driver.ExecuteStatement(command, new String[] { key, value });
|
boolean status = driver.ExecuteStatement(command, new String[] { key, value });
|
||||||
|
GlobalLog.Log(LogFilter.Database, "CreateKey status: " + status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transforms a result into a string if possible.
|
// Transforms a result into a string if possible.
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import jdk.nashorn.internal.runtime.logging.DebugLogger;
|
||||||
import utils.GlobalLog;
|
import utils.GlobalLog;
|
||||||
import utils.LogFilter;
|
import utils.LogFilter;
|
||||||
|
|
||||||
@@ -119,6 +121,7 @@ public class JDBCDriverSQLite extends JDBCDriver
|
|||||||
if(args != null && args.length > 0)
|
if(args != null && args.length > 0)
|
||||||
{
|
{
|
||||||
PreparedStatement statement = connection.prepareStatement(command);
|
PreparedStatement statement = connection.prepareStatement(command);
|
||||||
|
GlobalLog.Log("COMMAND" + command);
|
||||||
|
|
||||||
for(int i = 0; i < args.length; ++i)
|
for(int i = 0; i < args.length; ++i)
|
||||||
statement.setString(i + 1, args[i]);
|
statement.setString(i + 1, args[i]);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package network;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public enum JDBCStatementType
|
||||||
|
{
|
||||||
|
Insert (0), Update(1), Select(2);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private JDBCStatementType(int value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<JDBCStatementType> valueOf(int value)
|
||||||
|
{
|
||||||
|
return Arrays.stream(values()).filter(role -> role.value == value).findFirst();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user