V
V
Vanes Ri_Lax2015-09-21 13:17:05
MySQL
Vanes Ri_Lax, 2015-09-21 13:17:05

How to find out how many rows a query returned?

Hello, I wrote a simple program that should just find out how many records are in the database for a specific request, this is what I have:

public class Main {
    public static void main(String[] args) {
        try {
            DriverManager.registerDriver(new Driver());
            Connection c = DriverManager.getConnection("jdbc:mysql://host/dbname", "login", "pass");
            
            Statement s = c.createStatement();
            ResultSet rez = s.executeQuery("SELECT id FROM chel");
            
            
            
            
        } catch (SQLException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Can you please tell me how to find out how many rows are returned by my request?
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2015-09-21
@vanesxl

No way to know.
Or, before the main query, execute SELECT count(*) FROM TABLE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question