Solved

MS Access and JBDC-ODBC problem , cannot rs.previous()

Posted on 2004-09-23
8
297 Views
Last Modified: 2008-02-01
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();
                  rs.next();    // move 2 records
                  txtTel.setText(rs.getString("title"));            
                  txtareaAddress.setText(rs.getString("year"));  
                           
             rs.previous(); << --- ERROR
             // Rest of codes...
0
Comment
Question by:Shinjikun
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 12131110
previous throws an SQLException if the result set type is TYPE_FORWARD_ONLY
0
 
LVL 92

Accepted Solution

by:
objects earned 62 total points
ID: 12131111
try using the following to create your statement:

Statement s = con.createStatement(  ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 63 total points
ID: 12131115
I do not think ODBC supports this operation. But you can always try.

Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 92

Expert Comment

by:objects
ID: 12131124
If the driver doesn't support it then you'll need to read the result set into a list and then scroll thru that list.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12131162
Do you really need to go backwards? Or are you just playing around?
Because in the posted code I don't see any need to "jump around" like that. ;°)
0
 

Author Comment

by:Shinjikun
ID: 12131268
i need to create a DataNagivator where i can traverse my records to and fro. The codes are just to illustrate my problem.

Statement s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
Statement s = con.createStatement(  ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

both seems to work fine .. how do i spilt the reward points ?
0
 
LVL 35

Expert Comment

by:girionis
ID: 12131291
:)
0
 
LVL 92

Expert Comment

by:objects
ID: 12131318
(:
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 119
SHA2 certs for IIS AND Java? 2 113
Facing this issue for maven proxy setting 2 20
servlet and mdb, jms error 1 33
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

860 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