wood burning stoves 2.0
The moose likes JDBC and Relational Databases and the fly likes ResultSet 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 "ResultSet" Watch "ResultSet" New topic


Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99

What type of object is returned when a ResultSet is executed??

Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
ResultSet never get executed. Its the statement which get executed. When a statement is executed a resultset is returned which contains all the records which the specified statement has fetch.
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
To add a little to the previous response, when dealing with a Statement, there are three types of execute methods:

1) "executeQuery()" is used for doing a SELECT statement, and will return a ResultSet.

2) "executeUpdate()" is used for doing a DELETE, UPDATE or INSERT statement, and will return an int (number of rows affected).

3) "execute()" is used for multiple operations, or when the query type is unknown, and will return a boolean (read the doc as to the meaning since it's too complicated to explain here).

Some databases will let you get away with calling "executeQuery()" with a DELETE, UPDATE or INSERT, and others are more strict. But it's good to get in the habit of calling the appropriate method.

While it's true that you can't execute a ResultSet, with the JDBDC 2.0 specification you can udpate the database via the ResultSet. The methods are all "void", so don't return anything.

Cheers ...
[ May 20, 2004: Message edited by: Wayne L Johnson ]
Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
I meant when statement is excuted ResultSet is returned and what is the nature of it, is that in the form of objects, records, etc...??
[ May 24, 2004: Message edited by: Karthik Ganesh ]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Well, the easy answer is that everything is an object.

[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
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
When statement is executed it return the object of ResultSet. This resultset object contains all the data from database table which is returned by your specified query.

You can navigate resultset using its next() and previous() methods or fist() and last() methods. You can get the data against any column using getXXX() methods of Resultset.
I agree. Here's the link: http://aspose.com/file-tools
subject: ResultSet
It's not a secret anymore!