diff --git a/pom.xml b/pom.xml index 5ac15dc..368f849 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.goldendeveloper MYSQL-Api - 5.6 + 5.7 jar https://github.com/Golden-Developer/MYSQL-Api diff --git a/src/main/java/de/goldendeveloper/mysql/entities/Row.java b/src/main/java/de/goldendeveloper/mysql/entities/Row.java index 8f50cb3..dc36a17 100644 --- a/src/main/java/de/goldendeveloper/mysql/entities/Row.java +++ b/src/main/java/de/goldendeveloper/mysql/entities/Row.java @@ -22,13 +22,13 @@ public class Row implements QueryHelper { /** * Represents a row in a database table. - * + *

* The Row class contains methods to retrieve and modify data in the corresponding row of the table. * - * @param table The Table object representing the table the row belongs to. + * @param table The Table object representing the table the row belongs to. * @param column The Column object representing the column in the row. - * @param mysql The MYSQL object representing the connection to the database. - * @param item The value of the column in the row. + * @param mysql The MYSQL object representing the connection to the database. + * @param item The value of the column in the row. */ public Row(Table table, Column column, MYSQL mysql, String item) { this.db = table.getDatabase(); @@ -51,13 +51,11 @@ public HashMap getData() { exportMap = executeQuery(query, rs -> { HashMap map = new HashMap<>(); ResultSetMetaData rsMetaData = rs.getMetaData(); - if (rs.next()) { - for (int i = 1; i <= rsMetaData.getColumnCount(); i++) { - if (rs.getString(rsMetaData.getColumnName(i)) != null) { - map.put(rsMetaData.getColumnName(i), new SearchResult(rs.getString(rsMetaData.getColumnName(i)))); - } else { - map.put(rsMetaData.getColumnName(i), null); - } + for (int i = 1; i <= rsMetaData.getColumnCount(); i++) { + if (rs.getString(rsMetaData.getColumnName(i)) != null) { + map.put(rsMetaData.getColumnName(i), new SearchResult(rs.getString(rsMetaData.getColumnName(i)))); + } else { + map.put(rsMetaData.getColumnName(i), null); } } return map; @@ -79,7 +77,7 @@ public void setExportMap(HashMap newMap) { * Sets the value of a specific item in the column. * * @param column The Column object representing the column to set the value for. - * @param item The new value to set for the column. + * @param item The new value to set for the column. */ public void set(Column column, Object item) { executeUpdate("UPDATE `" + this.getTable().getName() + "` SET `" + column.getName() + "` = '" + item.toString() + "' WHERE `" + this.column.getName() + "` = '" + this.item + "';", mysql); @@ -134,7 +132,7 @@ public int getId() { * Deletes the row from the database table associated with this object. * The deletion is performed based on the value of the column in the row. * The SQL query executed is as follows: - * DELETE FROM `tableName` WHERE `columnName` = 'columnValue'; + * DELETE FROM `tableName` WHERE `columnName` = 'columnValue'; * * @see Row#getTable() to retrieve the table associated with this row * @see Row#column to retrieve the column associated with this row diff --git a/src/main/java/de/goldendeveloper/mysql/entities/Table.java b/src/main/java/de/goldendeveloper/mysql/entities/Table.java index 2caf8ae..0c7e15c 100644 --- a/src/main/java/de/goldendeveloper/mysql/entities/Table.java +++ b/src/main/java/de/goldendeveloper/mysql/entities/Table.java @@ -225,7 +225,8 @@ public boolean existsColumn(String name) { */ public boolean existsRow(Column column, String item) { String query = "SELECT EXISTS(SELECT * FROM `" + this.getName() + "` WHERE `" + column.getName() + "` = '" + item + "')"; - Boolean exists = executeQuery(query, rs -> rs.next() && rs.getBoolean(1), mysql); + Boolean exists = executeQuery(query, rs -> rs.getBoolean(1), mysql); + System.out.println("229: existsRow : " + exists ); return exists != null && exists; }