This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
hi folks i have got a java program below for reading records from the last.it compiles fine.but when i run it says invalid cursor type. i have used ms-access 2000 and created a dsn entry.i am using jdk1.3. will jdbc-odbc connectivity work fine only for forward record fetch.pl clarify. regards ram ganesh
import java.sql.*; class test{ public static void main(String args[]) throws Exception{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc dbc:test"); Statement stmt=con.createStatement(ResultSet.FETCH_REVERSE,ResultSet.CONCUR_READ_ONLY); ResultSet ab=stmt.executeQuery("Select * from ram"); while(ab.next()){ System.out.println(ab.getRow()); System.out.println(ab.getString(2)); if (ab.getRow()==1) ab.previous(); } } } Exception in thread "main" java.sql.SQLException: Invalid Cursor Type. at sun.jdbc.odbc.JdbcOdbcStatement.initialize(JdbcOdbcStatement.java:140 ) at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(JdbcOdbcConnection.j ava:420) at test.main(test.java:6)
kumar lakkapragada
Greenhorn
Joined: Apr 27, 2001
Posts: 4
posted
0
Hi, while creating statement use this "stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);" Then, u can be able to use resultset.first() and resultset.last() and other functions suitable for ur application. Hope this will work for u. Hava a good day.
ResultSet.FETCH_REVERSE is only a performance suggestion to the database that you will be processing the resultset in a reverse direction. And to compound the problem, the driver can just ignore your suggestion! If you want to use this suggestion you have to create a scrollable resultset(like above) then move to the end of the resultset and iterate through it backwards...
if you want the resultset "physically" returned to you in a reverse order you must include an order by clause in your select statement to arrange this. Jamie
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.