Solved

cannot rs.previous()

Posted on 2004-09-22
3
213 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now