JDBC error
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Scott_Allan
Posted On:   Monday, March 24, 2003 09:56 PM

I may be going about this completely wrong and would appreciate some advice. I am trying to design way to make multiple calls from a client to a Session Bean ResultSet to be able to scroll backward and forward 20 records at a time. I can figure out how to retrieve the next 20 records going forward from a certain ID number but how do I go about retrieving the previous 20 records? I thought I could create a stateful session bean to retain the state ResultSet and scroll back and forth. I have no idea how to fix this error I'm getting only on the client side when the session bean is processing. For some reason it does not like my con.createStatement parameters. I got the following error when I added ResultSet.HOLD_CURSORS_OVER_COMMIT:    More>>

I may be going about this completely wrong and would appreciate some advice. I am trying to design way to make multiple calls from a client to a Session Bean ResultSet to be able to scroll backward and forward 20 records at a time. I can figure out how to retrieve the next 20 records going forward from a certain ID number but how do I go about retrieving the previous 20 records? I thought I could create a stateful session bean to retain the state ResultSet and scroll back and forth.



I have no idea how to fix this error I'm getting only on the client side when the session bean is processing. For some reason it does not like my con.createStatement parameters. I got the following error when I added ResultSet.HOLD_CURSORS_OVER_COMMIT:



java.rmi.RemoteException: com.sun.enterprise.resource.JdbcXAConnection$J
dbcConnection.createStatement(III)Ljava/sql/Statement;
java.rmi.NoSuchObjectException: CORBA OBJECT_NOT_EXIST 9999 No; nested exception
is:
org.omg.CORBA.OBJECT_NOT_EXIST: vmcid: 0x2000 minor code: 1807 compl
eted: No


My code is something similar to this:


String dbName = "java:comp/env/jdbc/Cloudscape";

String selectStatement ="SELECT "p"."personID", MAX("p"."sequenceNumber") FROM "PersonBeanTable" "p" group by "p"."personID"";

InitialContext ic = new InitialContext();

DataSource ds = (DataSource) ic.lookup(dbName);

Connection con = ds.getConnection();

con.setAutoCommit(false);

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);

stmt.setMaxRows(20);

ResultSet resultSet = stmt.executeQuery(selectStatement);

   <<Less

Re: JDBC error

Posted By:   Ivo_Limmen  
Posted On:   Monday, March 24, 2003 11:27 PM

Why not place the responsability of the paging of the ID's at the session bean? By entering the bean for the first time it will retrieve the MIN(id) and MAX(id) and the user gives the maxPerPage. The sessionbean calculated the range of records that will be shown with each call. Plus I would use a PreparedSatement for faster performance.
About | Sitemap | Contact