There is such code:
PreparedStatement statement = null; ResultSet result = null; String query = "SELECT passenger_id, name, surname, dateOfBirth FROM passengers " + " WHERE passenger_id IN " + " (SELECT passenger_id FROM tickets " + " WHERE bus_id=?)"; statement = connection.prepareStatement(query); statement.setInt(1, bus.getBusId()); result = statement.executeQuery(query); The query should return the table, and it works if executed from the MySQL console. However, when trying to execute a program, the following error occurs: 
I would be grateful for the help.
result = statement.executeQuery();- rjhdby