jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes Best Practice: Where to put database in Web Application (Tomcat as one example)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Best Practice: Where to put database in Web Application (Tomcat as one example)?" Watch "Best Practice: Where to put database in Web Application (Tomcat as one example)?" New topic
Author

Best Practice: Where to put database in Web Application (Tomcat as one example)?

Bob Hodges
Greenhorn

Joined: Feb 02, 2007
Posts: 10
To all,

When building a web application, what is the norm/best practice when you want to make it as stand-alone as possible? From what I've read, it's considered a very bad idea to just create a /data directory in your web app and use the embedded driver. It looks like there are (my assumptions, probably wrong), only a limited set of options here:

a) Create a /data directory, make sure your web app uses an exploded deployment and then the embedded driver can work against the files in the web apps /data directory
b) Create a /data directory somewhere the web server has read/write privs and use a mechanism to have the web server startup the database prior to your app starting. This assumes network (e.g. local host) connections/drivers.
c) Have the database started and running outside of the web server. This could be a local or remote machine and once again a network connection. However, in my case this would mean a separate java instance (Java database is being used) and the associated memory hit.

I know I've left out other options such as jndi, connection pools, etc. What I'm trying to accomplish (and its my ignorance) is that the web app can be easily deployed and run as self-contained as possible.

Hope this makes sense,

My thanks,

Bob Hodges
ntumba lobo
Ranch Hand

Joined: Oct 21, 2008
Posts: 180
What I can say is that the options you left out (JNDI, connection pool etc) are actually the norm/best practices for enterprise applications.
Aiming for a stand alone application is a good thing but it must not be at the expense of the portability which is important in the real world as things change frequently.
So you dont want to embed too much vendor specific stuff in your app that's why you have external conf like JNDI and all...

I hope that makes sense to you


SCJP 5 , SCWCD 5, SCEA 5
Bob Hodges
Greenhorn

Joined: Feb 02, 2007
Posts: 10
Ntumba,

Thanks for the reply. It makes perfect sense and thanks for the input. I was over thinking the issue and trying to make it more complex than it is.

Bob H
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

The database should be completely independent of the web app. The web app uses a JDBC URL to access the DB and should care less where it is.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Best Practice: Where to put database in Web Application (Tomcat as one example)?