From 9e9759394edc0956b4699bc74daf7f09280762c4 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Fri, 24 May 2019 01:06:11 -0700 Subject: [PATCH] = Statement type updates --- src/core/DatabaseDriver.java | 6 ++++-- src/network/JDBCDriverSQLite.java | 3 +++ src/network/JDBCStatementType.java | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/network/JDBCStatementType.java diff --git a/src/core/DatabaseDriver.java b/src/core/DatabaseDriver.java index ee2b84a..83fd0eb 100644 --- a/src/core/DatabaseDriver.java +++ b/src/core/DatabaseDriver.java @@ -87,7 +87,8 @@ public class DatabaseDriver private void UpdateKey(String key, String value) { 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 @@ -111,7 +112,8 @@ public class DatabaseDriver private void CreateKey(String key, String value) { 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. diff --git a/src/network/JDBCDriverSQLite.java b/src/network/JDBCDriverSQLite.java index 98a9688..ef3115a 100644 --- a/src/network/JDBCDriverSQLite.java +++ b/src/network/JDBCDriverSQLite.java @@ -7,6 +7,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; + +import jdk.nashorn.internal.runtime.logging.DebugLogger; import utils.GlobalLog; import utils.LogFilter; @@ -119,6 +121,7 @@ public class JDBCDriverSQLite extends JDBCDriver if(args != null && args.length > 0) { PreparedStatement statement = connection.prepareStatement(command); + GlobalLog.Log("COMMAND" + command); for(int i = 0; i < args.length; ++i) statement.setString(i + 1, args[i]); diff --git a/src/network/JDBCStatementType.java b/src/network/JDBCStatementType.java new file mode 100644 index 0000000..2e08c33 --- /dev/null +++ b/src/network/JDBCStatementType.java @@ -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 valueOf(int value) + { + return Arrays.stream(values()).filter(role -> role.value == value).findFirst(); + } +}