Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Java JDBC in oracle 10g (http://www.programmingforums.org/showthread.php?t=15588)

cwl157 Apr 10th, 2008 3:43 PM

Java JDBC in oracle 10g
 
I need to use the JDBC to access a database in Oracle 10g. I need to be able to go through the rows of a table more then once. I have created the ResultSet and ResultSetMetaData to retrieve the number of columns per row. I use a while loop to go through the ResultSet calling the next() method each time to get the next row. Then I print the rows. However, after I go through each row of the table once with the next() method of ResultSet, I need to go through the table from top to bottom again. Is there a method that will place the cursor that goes through the rows back at the top row? I looked up the ResultSet interface in the java documentation and it has a beforeFirst() method that will do just that, however when i put that in my program it compiles ok but when i try to run it I get an SQLException when trying to run the method. That tells me that java JDBC accepts it but Oracle 10g does not. If anyone is familar with this stuff do you know of a method that is compatible with Oracle 10g database that will take the cursor from the last row of the database and put it at the top so when the next() method is called in a while loop it will cycle through all the rows of the table a second time? Thanks.

cwl157 Apr 10th, 2008 4:13 PM

Re: Java JDBC in oracle 10g
 
never mind i got it. It has to do with how the Statement is set up. You have to pass two fields into the Connection like this:

:

Statementstmt
=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

That will make the beforeFirst() method of ResultSet work


All times are GMT -5. The time now is 11:04 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC