• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ned to change servlet code to pure java

 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am trying to use the Tomcat Data Sources,connection pooling.The example I saw used servlets,can you please tell me how to change the servlet to equivalent java code,as i dont know servlets.I have marked(----) the statements,which need to be changed.I have marked the last one(return results),because I dont know where to fit that statement.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jas,
Connection pooling uses a datasource. This works if your class runs on the server (servlet, ejb, ...) It also works if a servlet or ejb is calling your class. If this is not the case, you need to substitute the part of the code that gets the connection with the DriverManager code (from your other post.)

As for returning the resultset, I'm not sure what the confusion is. Are you trying to process it?
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks jeanne again,
I have a jsp,which fires in the query to this class,which returns the resultset to another java class,which cooks the data and sends it back to the jsp.I have worked on the code,I just want to know when and where should I call the close() method.Here's my new code:
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jas,
The close method looks good.

"which returns the resultset to another java class,which cooks the data" - This is the class that needs to call your newly written close method.
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne,
After making changes to Tomcat and configuring the connection pool,I am able to reduce the database access time vastly.But there is still a delay,how can i check the no.of connections that are open,because i am not calling the close routine anywhere.Please help me again.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34870
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jas,
For that you need a profiling tool.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic