aspose file tools
The moose likes JDBC and the fly likes code for Database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "code for Database connection" Watch "code for Database connection" New topic
Author

code for Database connection

Rekha Gaikwad
Ranch Hand

Joined: Jul 25, 2005
Posts: 36
Hi,
I am developing an application using Java/JSP and web container is tomcat. Can anybody guide me how should I go abt writing connection class?
Is it ok to make connection through servlet init method?
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3666
    
    2

Do you want to write your own connection class? Unless you're developing your own database, you generally want to use an exisitng Connection class with a JDBC driver that comes with your database.

I'd recommenting using lazy instantiation (only create it the first time you need it) for your database connection for two reasons: 1) better performance overall 2) better control- you can close it after you are done so that you dont run out of connections


My Blog: Down Home Country Coding with Scott Selikoff
Milan Jagatiya
Ranch Hand

Joined: Jan 01, 2007
Posts: 164
better you refer below link ...and go for "JDBC Data Sources"...
it helps....
TOMCAT JNDI-RESOURCES


Milan.<br />I can because I think I can...
Rekha Gaikwad
Ranch Hand

Joined: Jul 25, 2005
Posts: 36
Thanks for your help guys.Really Appreciate it!!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: code for Database connection
 
Similar Threads
Is HTTP connectionless or connection oriented
Head First OOAD
HTTP Connection less or Connection based?
H2 database consule lockings
Jboss connection pool not releasing the connection from pool