Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting a JAVA Class to a MAIN class

 
Wayne Burr
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a beginner and the following problem I have pulled just about all my hair out trying to figure out. I'm sure it is a easy fix but the things I have tried are not working out.
I have a JAVA file that I need to call from a JSP and return the result set and that is it. Here is the JAVA code from what it was before I got ahold of it:

I need to know what needs to be done to return the recordset back to my JSP page. Any help will be great, and thanks in advance!
(edited by Cindy to format code)
[ November 05, 2002: Message edited by: Cindy Glass ]
 
Paul Fonz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had this problem. Firstly, you call the Java class as a bean, using the <usebean> tag.
As for returning the ResultSet, I found it easiest to create my own version of the Result Set using the ResultSet MetaData() while the ResultSet is open. You can then close() the original ResultSet, and use your own class to access the data.
Here is the constructor of the class I use for this purpose, to give you an idea:
 
Jesse Beaumont
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The problem as was quite rightly pointed out in the previous post is that the ResultSet object is connected. That is, if you close the statement it is associated with, the ResultSet no longer has any meaning (it's a UML composition, with the unfortunate aside that Java does not support compositions explicitly )
The solution I use is to simply copy the contents of the RS into a 2D array or some similar construct (ArrayLists are probably easier)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!