Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
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: 31634

Note that you have to point to the first row before you call So it looks like:

[OCA 8 book] [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:
subject: a basic question