This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes define database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "define database connection" Watch "define database connection" New topic
Author

define database connection

fang eve
Greenhorn

Joined: Jun 22, 2006
Posts: 26
Is it better to write all the database url, username, path in the web.xml or create 1 java function for it?
[ June 22, 2006: Message edited by: fang eve ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Defining connection details in a suitable configuration file (possible web.xml) is usually better. That way you don't have to recompile your code to change databases.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
fang eve
Greenhorn

Joined: Jun 22, 2006
Posts: 26
oh.. but as in security concern web.xml is better?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Who has access to web.xml (or whatever configuration file you may choose)? In a properly secured application, only the administrator.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: define database connection
 
Similar Threads
Tech Word Game
Large Files
Sharing data between web app's
Shopping Cart - Part 2
share data