From 7547c4780b44894cc985a327e745e6ee8ec7abbd Mon Sep 17 00:00:00 2001 From: creeper Date: Wed, 14 Jan 2026 16:28:04 +0100 Subject: [PATCH] I need to COMPILE --- src/CreeperSQL.java | 51 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/src/CreeperSQL.java b/src/CreeperSQL.java index 4c4a265..141b0bd 100644 --- a/src/CreeperSQL.java +++ b/src/CreeperSQL.java @@ -70,7 +70,9 @@ public class CreeperSQL { //connect - /** Connect using previously set config (host, user, pass, database) */ + /** + * Connect using previously set config (host, user, pass, database) + */ public void connect() throws IllegalStateException { if (host == null || user == null || pass == null || database == null) { throw new IllegalStateException("[CreeperSQL] Config not set! Call setConfig() or readMinecraftConfig() first."); @@ -103,7 +105,9 @@ public class CreeperSQL { ResultSet rs = meta.getTables(database, null, "%", new String[]{"TABLE"}); while (rs.next()) tables.add(rs.getString("TABLE_NAME")); rs.close(); - } catch (SQLException e) { e.printStackTrace(); } + } catch (SQLException e) { + e.printStackTrace(); + } return tables; } @@ -139,19 +143,44 @@ public class CreeperSQL { return result; } - public boolean createTable(String sql) { return sqlAction(sql).error == null; } - public boolean dropTable(String tableName) { return sqlAction("DROP TABLE IF EXISTS " + tableName + ";").error == null; } - public boolean insert(String sql) { return sqlAction(sql).affectedRows > 0; } - public boolean update(String sql) { return sqlAction(sql).affectedRows > 0; } - public boolean delete(String sql) { return sqlAction(sql).affectedRows > 0; } + public boolean createTable(String sql) { + return sqlAction(sql).error == null; + } - public void close() { try { if (connection != null) connection.close(); } catch (SQLException ignored) {} } + public boolean dropTable(String tableName) { + return sqlAction("DROP TABLE IF EXISTS " + tableName + ";").error == null; + } + + public boolean insert(String sql) { + return sqlAction(sql).affectedRows > 0; + } + + public boolean update(String sql) { + return sqlAction(sql).affectedRows > 0; + } + + public boolean delete(String sql) { + return sqlAction(sql).affectedRows > 0; + } + + public void close() { + try { + if (connection != null) connection.close(); + } catch (SQLException ignored) { + } + } public static class QueryResult { public List> rows = new ArrayList<>(); public int affectedRows = 0; public String error = null; - public boolean hasError() { return error != null; } - public boolean hasRows() { return !rows.isEmpty(); } + + public boolean hasError() { + return error != null; + } + + public boolean hasRows() { + return !rows.isEmpty(); + } } -} +} \ No newline at end of file