File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet" Watch "ResultSet" New topic
Author

ResultSet

Ananth Ram
Ranch Hand

Joined: Jan 18, 2001
Posts: 99
Hi,

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

Tx,
Karthik
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

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


[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
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.
 
 
subject: ResultSet
 
Similar Threads
Resultset
handle empty recordset
Problem in getting multiple resultsets from Oracle Stored Procedure
how can show the data in database to jtable??
JSP & JDBC