This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC problem" Watch "JDBC problem" New topic
Author

JDBC problem

kandula chandrasekhararao
Greenhorn

Joined: May 16, 2003
Posts: 7
hi
may i know how to use properties file for connecting to a database?
Advanced thanks
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
There are lots of ways of doing this, but this may help you a bit.

This example uses the Oracle "thin" driver, but it should work for any database/driver combination. In your code you will need to read in the properties either as a "Properties" instance or "ResourceBundle" instance, and then get the values appropriately.
If you go the "Properties" route, this would work (shared for its functionality, not for style points):

There are several ways of reading in a properties file, this one being less elegant. If you are running in a Web environment I recommend that you use the "ResourceBundle" class.
Give it a try ...
[ September 04, 2003: Message edited by: Wayne L Johnson ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JDBC problem