Solved

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

Posted on 2004-09-23
8
271 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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