aspose file tools*
The moose likes JDBC 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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark " line just after result of query" Watch " line just after result of query" New topic
Author

line just after result of query

Mohammed Mudassir Mohiuddin
Greenhorn

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
author
Bartender

Joined: May 14, 2008
Posts: 5779
    
    7

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
Bartender

Joined: Oct 14, 2005
Posts: 18154
    
    8

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: http://aspose.com/file-tools
 
subject: line just after result of query
 
Similar Threads
SQLException
MySql 5.0.67 sql statement, command line versus jdbc PreparedStatement
how to create MySql stored procedure?
MysqlDataTruncation
MySQL - Returning Tables in Functions/SPs/Views