As far as I know getInt(column index)retrieves a column value from the current row, but I don't understand its purpose in a situation like this. Doesn't the SQL statement SELECT COUNT(*) FROM Gyujtoallomasok
already count the rows in the table? If so, why do we need the rest?
public int count() {
try (Connection connection = DriverManager.getConnection(URL);
Statement statement = connection.createStatement()) {
ResultSet resultSet = statement.executeQuery("SELECT COUNT(*) FROM Gyujtoallomasok");
if (resultSet.next()) {
int count = resultSet.getInt(1);
return count;
}
} catch (SQLException exception) {
// TODO: log
}
return -1;
}