File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP, Servlet & JDBC

 
Srikanth Madduri
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to develop a project using JSP, Servlet and JDBC. The JSP gets the parameters from the User and passes to HttpServlet. The servlet validates and submits a query to the database using
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection mycon = DriverManager.getConnection("jdbc dbc:mydb");
Statement mystmt = mycon.createStatement();
ResultSet rs = mystmt.executeQuery(sqlString);
Now the problem I am facing is to capture the contents of the the ResultSet and pass it to the client. I realised that ResultSet is not Serilaizable hence need to move it to a Vector object and then send to the client. But to send a huge Vector is not a very effective solution. It's ok to get a few(say 20) records at a time. But to print to the local printer, the whole resultset needs to be printed. So is it necessary to send the whole resultset to the client?
Could someone give more information on this, please. None of the tutorials seem to deal with this situation. Or am I doing something really unusual? Is there a better way to do this? Could you give me the code as well.
Thanks
Srikanth
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Will ResultSet.getBinaryStream() helps you in anyway...?
 
Tieyi Guo
Greenhorn
Posts: 15
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
As I think, you should get the retrieved value out of the ResultSet anyway since you could not send it back to client directly. Then why do not you put the retrieved values together with their names into a session. For sure session object is passwd back and forth between the client and servlet. I am not sure how efficient it will be compared with sending a big vector by yourself, but I assume it will be a little bit better in both efficency and security.
Hope this helps.

Tieyi
 
Srikanth Madduri
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tieyi,
Thanks for giving valuable suggestion. I found that I had not understood the ResultSet correctly. A JSP can receive the ResultSet object from a Bean. The records in the ResultSet can be displayed on a JSP directly.
Thank all
Srikanth
 
mepurvi dholakia
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell me how can a JSP receive the ResultSet object from a Bean ?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic