Solved

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

Posted on 2004-09-23
8
282 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
what is the difference between "sudo su" and "su - root" 6 106
Cipher Configuration on Apache HTTPD 4 53
Error trying to install RTMT Win7 5 41
use lov values 2 36
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

895 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

12 Experts available now in Live!

Get 1:1 Help Now