?
Solved

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

Posted on 2004-09-23
8
Medium Priority
?
313 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
[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
  • 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 186 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 189 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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 about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

762 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