jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes a basic question 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 "a basic question" Watch "a basic question" New topic

a basic question

Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131

how do you execute this query?

select count(*) from tablename;

the return type is int right?

so how do you execute, i mean

using stmt.execute or executeUpdate or executeQuery ???
latha yeduguri

Joined: Jun 24, 2005
Posts: 17
You can do that with stmt.executeQuery.
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1704
Use executeQuery() method. It will return you ResultSet.
Using getInt() method of ResultSet you can get the count.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33107

Note that you have to point to the first row before you call rs.next(). So it looks like:

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: a basic question
It's not a secret anymore!