• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

applet-servlet - creating objects from resultset

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Could somebody pl help me solve this problem ?

i am trying to send a vector of student objects from servlet to applet.I have a student class(student) for creating the student objects,add to a vector and then send the vector back to the applet.Now the query in the servlet returns a resultset having a number of records and about 50 fields(columns).I
need to loop through the resultset to create the object for each record.
Is there any method by which u can pass the first RECORD
in the resultset as a parameter of type RESULTSET to the class student constructor, to create the student object?
.tried this code....
.....
cst.registerOutParameter(5,OracleTypes.CURSOR);
cst.execute();
rsDet = (ResultSet)cst.getObject(5);
Vector vS = new Vector();
while(rsDet.next()){
vS.addElement( new student(rsDet) );
}
.......
.......
but got the error..
exception....Closed Resultset: next
java.sql.SQLException: Closed Resultset: next
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java)
at server_frs.getSubDet(server_frs.java:88)........

The query returns three records....No error msg is thrown however when the first record is added to the vector. Only during the second loop, i think ,the error is thrown.
If a fn is used, then u need to send 50 variables for each record to create the object. I want to avoid that.
Any idea on how to send each record from the resultset to create the object?
Would appreciate any help
rgds
csb
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
csb,
May I be so bold as to suggest that you try the javax.sql.rowset.CachedRowSet interface (instead of a "Vector"), since it is probably more appropriate to the situation you describe.

Of-course, you need to locate an implementation of the interface. Since it appears that you are using an Oracle database (although I could not ascertain the version), you may find an implementation through the following Web page:

http://tinyurl.com/6nj4x

Good Luck,
Avi.
 
chelakkad ben
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Avi
Thanks for the reply,Avi. CachedRowSet seems a good idea!! Afterall i can scoll throught the resultset in the client and display..It
is scrollable too.But will it work with IE 5 and above?
thanks
csb
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's in an applet and you've made the needed libraries (jars) available it won't matter what browser it's in.
 
It means our mission is in jeapordy! Quick, read this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic