Solved

cannot rs.previous()

Posted on 2004-09-22
3
221 Views
Last Modified: 2010-05-18
Hi, I developed a simple java program and used jdbc-odbc to link to a local MS Access database to do some simple adding / deleting and traserving of records. Everything works fine till i used rs.previous();

It gives me an error saying "ERROR: java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY"...  How do i resolve this ? I wanna access my previous records

try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              String dataSourceName = "Testdatabase";
              String dbURL = "jdbc:odbc:" + dataSourceName;
              Connection con = DriverManager.getConnection(dbURL, "","");
              Statement s = con.createStatement();
              s.execute("select * from publications");
              ResultSet rs = s.getResultSet();       
                        rs.next();
              
                    //txtTel.setText(rs.getString("title"));             
                    //txtareaAddress.setText(rs.getString("year"));                               
              rs.previous(); << --- ERROR
              // Rest of codes...
0
Comment
Question by:Shinjikun
3 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 250 total points
ID: 12130315
From the Microsoft Access help file, referencing the Execute method of a connection object:

The returned Recordset object is always a read-only, forward-only cursor. If you need a Recordset object with more functionality, first create a Recordset object with the desired property settings, then use the Recordset object's Open method to execute the query and return the desired cursor type.

I don't know the exact syntax for Java but I imagine it would look something like this:

ResultSet rs
rs.Open "select * from publications", s, 2, 3n
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question