File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes  line just after result of query 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 " line just after result of query" Watch " line just after result of query" New topic

line just after result of query

Mohammed Mudassir Mohiuddin

Joined: Jan 27, 2012
Posts: 1
Using JDBC how to retrieve "5 rows in set (0.00 sec)", line just after result of query.

Peter Johnson

Joined: May 14, 2008
Posts: 5852

I've used code like this:

I've always wanted to be able to do something like rs.getRowCount() instead, but having implemented a JDBC driver I realize how dangerous such as function is. The programmer will assume that it is a simple number that the driver can return, but in many case, in order to get that number, the driver has to get all of the rows first. At least, that is what the issue was with our database. So making the programmer do extra work might force him/her to think whether such a thing is a good idea (especially if the row count is possibly in the thousands or higher!)

JBoss In Action
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

However, to produce the posted output, all you need to do is to increment a counter for each row you read.
I agree. Here's the link:
subject: line just after result of query
jQuery in Action, 3rd edition