Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cannot rs.previous()

Posted on 2004-09-22
3
Medium Priority
?
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 1000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

688 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