File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes DriverManager.getConnection 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 "DriverManager.getConnection" Watch "DriverManager.getConnection" New topic


Vidya pr

Joined: Sep 10, 2001
Posts: 1
Could anybody help me out with this
con = DriverManager.getConnection(url,User,Pass);
ie.. instead of giving username and Password i wish to globalise the variables so that i can connect to various databases just by changing a single variable but its not working.
I wud b thankful if anybody cud help me with this .
Shiv Sidhaarth
Ranch Hand

Joined: Aug 06, 2001
Posts: 119
I am not getting ur question clearly. You can keep your URL, username and encrypted password in a text file. Then, read them thru ur appln and use them to connect to different database (Provided driver is same for diff. databases). If u have diff. driver, then include driver class name also in the text file. Hence, whenever u want to change datbase, u just need to change the text file. Is this, u wanted?
I agree. Here's the link:
subject: DriverManager.getConnection