jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Moving the Cursor in ResultSets..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Moving the Cursor in ResultSets..... " Watch "Moving the Cursor in ResultSets..... " New topic
Author

Moving the Cursor in ResultSets.....

sam patel
Ranch Hand

Joined: Jun 13, 2002
Posts: 103
I have posted this request couple of days and nobody has solved my problem yet. I am stuck with this problem
for almost a week.
So here is goes.......
I have an Applet-Servlet Communication which is done in JBuilder 7.0 using JDK 1.3
This is what Exactly what i am doing.
I am trying to reverse iterate through a resultset.
I am using JDBC-ODBC Bridge.
Before i had this Exception this is what i had before and it worked fine
I was doing the DB connection in Servlet to collect the Image names and sending that object back
to the Applet which displays the Image names in JLIST. After selecting the image name it goes back to the
Servlet to get the Image object and i was passing that object back to Applet to displays the tiff images.
But now what they want us to do is to use the XML to do the DB connection and get the Image names from DB and
display it in the Applet(jlisT GUI).
So from the ResultSet which contains the Image names i have to create a XML file and Display the image names.
This is what i am doing to create the XML file.
I am taking the ResultSet that i have in Servlet side. And from that i wrote this class which takes this resultset and creates the XML File.
XML file is created but it would not display the Image names in the Applet;
because after going through this class the ResultSet is at the end.
And i am using this resultSet again to display the image names in JLISt. But because it is at the end of the ResultSet I am getting this Exception.
===============================
java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
===============================
Also i have tried this:
======================================================================
PreparedStatement pstmt = con.prepareStatement("SELECT * from...",
ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
======================================================================
ANd did not make any difference.
So upon conclusion of this messy request.
Any help is highly appreciated.
Thanks in advance.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

This is a continuation of this discussion.
I still stand by this response:
"Sam: It sounds like you are doing nothing wrong. It looks like it is a limitation of your current ODBC driver that the jdbc dbc bridge is using to get the ResultSet. In order for you to use a scrollable resultset, you must upgrade your ODBC database driver to one that does support scrollable resultsets. Other than upgrading your driver, I see some other possibilities:
1. save the name of the image while you are reading the other values from the resultset and store them in a data structure of some kind(ArrayList/Vector?). When you need the name, you lookup the name in the data structure just as you would the resultset.
2.The other alternative may be to re-query the database for the information."
Also, I am not familiar with InterBase, nor do I have any references to any InterBase resources [as per your previous threads question]
Jamie
[ August 02, 2002: Message edited by: Jamie Robertson ]
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I did find this link
Premkumar N
Greenhorn

Joined: Apr 21, 2001
Posts: 22
As Jamie said. I feel that your JDBC driver is not supporting "SCROLL_SENSITIVE" ...
The option that I used in this scenario is .
Step1 : put the primary-key and the image name in a hash table
Step2: populate whatever GUI component you want with this list of names.
Step 3 : When u need to query the image form DB pass the stored "primary-key-id" to the DB and get the image.
Hope this helps rolleyes:
Thanks,
Prem :


<a href="mailto:pondyprem@yahoo.com" rel="nofollow">pondyprem@yahoo.com</a> <br />Sr.Programmer Analyst ( Bioinformatics)<br />Monsanto Entrprises
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Moving the Cursor in ResultSets.....
 
Similar Threads
Moving the Cursor in ResultSets.....
Applet Servlet Serialized Object
applet or jsp for comm with servlet ?
can HTML page be displayed using servlet in app-serv communication
Dispatching ResultSet object from Servlet to JSP