I need to COMPILE

This commit is contained in:
creeper 2026-01-14 16:28:04 +01:00
parent 216425e983
commit 7547c4780b

View File

@ -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<List<String>> 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();
}
}
}