aspose file tools*
The moose likes Performance and the fly likes J2EE Database Access .. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "J2EE Database Access .." Watch "J2EE Database Access .." New topic
Author

J2EE Database Access ..

prasad agarwal
Ranch Hand

Joined: Aug 24, 2006
Posts: 44
Hi all,..

Well this thread is just to discuss about efficient ways of accessing Database
from your J2ee applications.. I really want to hear from you guys

I am not using EJB or Hibernate at this moment..

This is what i am presently doing:

In web.xml i declare the JNDI DataSource name as a context-param

and then in ServletContextListener i perform a JNDI DataSource lookup
and store the datasource instance in ServletContext scope



Then in each servlet, i get the instance of DataSource name, make a connection,
perform SQL queries and close the connection



Now talking about how i perform SQL queries, i have another POJO class (Plain old java Object)
many queries as many methods in one POJO class .. As an example...



I create an Object of the POJO class and call these methods from the Servlet.
I am not saying anything wrong going on, but i just want to hear comments from you guys.

Any flaw?? What would be the best way to perform Database access - and perform SQL queries
in a J2EE web application ..?? Any improvements or changes i have to do ??

Thanks again
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Moved to performance forum...


My Blog: Down Home Country Coding with Scott Selikoff
prasad agarwal
Ranch Hand

Joined: Aug 24, 2006
Posts: 44
So whats up guys ??

can i assume that this design is good enough? without requiring any changes
if so, thanks
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
Here is a similar thread.

http://www.coderanch.com/t/304631/JDBC/java/Request-critique-better-way-database

Also, I wouldn't handle connections in the servlet. Hide the connections from the front end. Being as you are returning an ArrayList and not a ResultSet this should be easy enough to do.
[ September 20, 2006: Message edited by: steve souza ]

http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
prasad agarwal
Ranch Hand

Joined: Aug 24, 2006
Posts: 44
Hi steve ,

Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: J2EE Database Access ..