0

Possible Duplicate:
How do I get the row count in JDBC?

Hi,

How can I count a query in a row in MySQL database using sql count statement with JAVA?

tq

Community
  • 1
  • 1
user692495
  • 69
  • 2
  • 6
  • 13

2 Answers2

1

How about

select count(*) fromtable_name

Usage would be something like:

     int count;
     String table = ...
     Statement st = ...
     ResultSet rs = st.executeQuery("select count(*) from " + table);
     while (rs.next()){
      count = rs.getInt(1);
     }
Johan Sjöberg
  • 47,929
  • 21
  • 130
  • 148
0

If you are looking for a query to get the count :

SELECT COUNT(*) FROM MyTable
GuruKulki
  • 25,776
  • 50
  • 140
  • 201