I have such a method:
private static ResultSet select (Connection connection, String query) {
PreparedStatement selectQuery = null;
ResultSet resultSet = null;
try {
selectQuery = connection.prepareStatement(query);
resultSet = selectQuery.executeQuery();
selectQuery.close();
} catch (SQLException e) {
System.out.println(e);
}
return resultSet;
}
The thing is that the resultSet is always empty when I close the preparedStatement.
If I comment out the line with clothing preparedStatement //selectQuery.close();
everything is fine.
I close it after assigning value to the resultSet. So why it's empty?