aspose file tools*
The moose likes JDBC 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
Bookmark "a basic question" Watch "a basic question" New topic
Author

a basic question

Arul Jose
Ranch Hand

Joined: Jan 14, 2005
Posts: 131
Hi,

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
Greenhorn

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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a basic question