M
M
Maks Burkov2016-11-20 15:19:00
Java
Maks Burkov, 2016-11-20 15:19:00

Result Set error while working with jdbc, What does this error mean?

I receive an error message.
java.sql.SQLException: Before start of result set sql exception!
The cause of the error is not clear, can anyone explain?

String queryDataBase = "SELECT nickname,password,email FROM users  WHERE nickname = ? AND password = ? AND email = ?";


            PreparedStatement preparedStatement = connection.prepareStatement(queryDataBase);
            preparedStatement.setString(1, name);
            preparedStatement.setString(2, password);
            preparedStatement.setString(3, email);
            ResultSet resultSetQuery = preparedStatement.executeQuery();

            if (resultSetQuery != null){

                    if (resultSetQuery.getString("nickname").equals(name)) {
                        System.out.println(resultSetQuery.getString("nickname"));
                        if (resultSetQuery.getString("password").equals(password)) {
                            System.out.println(resultSetQuery.getString("password"));
                            if (resultSetQuery.getString("email").equals(email)) {
                                System.out.println(resultSetQuery.getString("email"));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
stanislav_slav, 2017-11-13
@stanislav_slav

Before fetching the data, try to call resultSetQuery.next(), the problem is that the cursor is before the first line, by calling this method you will move it to the first line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question