Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Get records count

  Asked By: Jason    Date: Feb 25    Category: Java    Views: 845
  

I have used a " prepareStatement " to search a table like code below.After running executeQuery, how can I distinguish number of records ? I want to print message if no data found.


PreparedStatement state = con.prepareStatement("SELECT * FROM tbname WHERE name = ?");
inputSearch =JOptionPane.showInputDialog( "Enter name to search " );
state.setString(1,inputSearch);
ResultSet result = state.executeQuery();

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Patricia Johnson     Answered On: Feb 25

you can get resultset.next() value to check if the result  set is empty or not.
for getting the number  of result :: you can count  it by an iteration on resultset.next()

 
Didn't find what you were looking for? Find more on Get records count Or get search suggestion and latest updates.




Tagged: