It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Row count in oracle..? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Row count in oracle..?" Watch "Row count in oracle..?" New topic

Row count in oracle..?

santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Hi Friends

Is is possible to get the number of rows from oracle table with out using ResultSet rst .next() method .

Creativity is nothing but Breaking Rules
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

No. But that is because you can't do anything with any ResultSet without first moving the cursor to a row. However, you can use a query to find out how many rows a query will return without having to iterate through the whole query ResultSet by using the count SQL function.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403

You can use select count(*) as my_count from table_name to get the number of row count from a table.

rs.getInt("my_count") will return you number of rows..

Ujjwal B Soni <baroda, gujarat, india> <+918866008962>
"Helping hands are better than praying lips......"
santhosh.R gowda
Ranch Hand

Joined: Apr 06, 2009
Posts: 296
Thanks all of us.....
I agree. Here's the link:
subject: Row count in oracle..?
It's not a secret anymore!