Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

help regarding implementing search within results  RSS feed

 
gaurav chaudhary
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting a resultset from database(MSSQLServer). Now, I am storing this in session. After that, if user searches within results, I want to search for furthur records in the records I got from the previous result set. So. I want to know how can i implement it using jsp,mssqlserver2000 and jdbc2.
thanks in advance
Gaurav chaudharygaurav@yahoo.com
 
Ken Pelletier
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to reconsider storing the ResultSet instance in the session. A ResultSet keeps the JDBC connection open, and your connections will pile up if a lot of sessions are created.
This presumes, of course, that you are creating a separate connection for each request - either with a connection pool or not. If not, then you're sharing the same connection, which will surely be the road to ruin.
You may, instead, consider adapting the ResultSet into another set of objects - whatever structure suits your purposes - at the time of the search.
This strategy uncouples the result data from the db connection, and may provide you with a cleaner, more expressive interface, which is abstracted away from the JDBC api.
You could create something as simple as a class that wraps an ArrayList of HashMaps, that also has methods to suit your paging back and forth among the rows (list elements) and accessors for the state you need.
You could then store that collection in the session. I think you'll find that dealing with that collection in all the presentation and paging logic code you write will make it well worth the minimal effort to create it.
You'd basically need an interface to get the size of the result ( no of rows ), a way to get a particular row ( by index position, say ) and accessors for each of the columns. You could use individual accessors, or just a simple getAttribute( int rowIndex, String attrName ) style.
 
gaurav chaudhary
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure I would consider that but this I did because at one time there would be maximum of two or three users on this project. But my main problem is how do I implement search within results so that user can search within the resultset I got previously.
thanks
gaurav
[ October 16, 2002: Message edited by: gaurav chaudhary ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!