It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes JDBC problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC problem" Watch "JDBC problem" New topic

JDBC problem

kandula chandrasekhararao

Joined: May 16, 2003
Posts: 7
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 ]
I agree. Here's the link:
subject: JDBC problem
It's not a secret anymore!