Hi, THis is part of yesterdays question, which i did not get much of help. I have an Applet-Servlet Communication which is done in JBuilder 7.0. This is what Exactly what i am doing. I am trying to reverse iterate through a resultset. I am using JDBC-ODBC Bridge. But am getting this error. =================== java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY ===================== According to: http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/index.html Accoring to this they are saying that In JDBC 2.0 you can move a result set's cursor backward as well as forward. They are saying i should use something like this: Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
But can someone show me how can i do this using the PREPAREDSTATEMENT instead of Statement.
Any help is highly appreciated. Thanks in advance.
**Note - you may experience problems if your ODBC driver does not support this functionality. It usually will not tell you that it could not create a scrollable resultset, it will just default it ( behind the scenes ) to TYPE_FORWARD_ONLY
Joined: Jun 13, 2002
Thank you for your Reply. I tried that preparedStatement and still i am getting the same error. THis actually what i am doing. This is what i had before and it worked fine I am doing the DB connection in Servlet and sending the object back to the Applet and displaying the tiff images. Before i display the image i have to select the image name from the JLIST which i get from the ResultSet. 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 contaings 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 againg to display the image names in JLISt. But because it is at the end of the ResultSet I am getting this error. java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY So upon conclusion of this messy request. I would greatly appreciate for any suggestions or help.
Sam: It sounds like you are doing nothing wrong. It looks like it is a limitation of your current ODBC driver that the jdbcdbc 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. Jamie [ August 01, 2002: Message edited by: Jamie Robertson ]
Joined: Jun 13, 2002
I am using JBuilder7 i think that contains the JDBC 2.0. Can You please tell me which ODBC database driver that does support the Scrollable resultset. Thanks for your help.
the jdbcdbc bridge you are using may jdbc 2.0 ( comes standard in the JDK 1.2 and up ) but the underlying implementation of your driver may not be. To upgrade to the most recent version of your driver, go to the homepage of your database and search for ODBC drivers for your database. **NOTE: just because you are using the latest version of the ODBC drivers, does not mean that they are 100% guaranteed to be fully JDBC 2.0 compliant, even though most popular databases do provide a high level of functionality. If I knew what database you were using, I might be able to direct you to some resources. Jamie [ August 01, 2002: Message edited by: Jamie Robertson ]