aspose file tools*
The moose likes Struts and the fly likes Dynamic Database Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply locked New topic
Author

Dynamic Database Connection

Jagadish Jain
Greenhorn

Joined: Apr 05, 2012
Posts: 8
Hello,

Im developing a project where in the connection to DataBase is static i.e Im hard coding the details of the database in createConnection() method.
Now Im required to dynamically connect to a database i.e in the first page of my project, the user enters the database details(servername,port,username,passowrd,servicename) and using this details my project should be connected to respective database.

One solution to this is to have my createConnection() method as createConnection(String serverName,String portNumber,
String userName,String pword,String s_id).
But my project is very vast and everywhere I have used createConnection() to connect to database, changing this method to createConnection(String serverName,String portNumber,
String userName,String pword,String s_id) everywhere is not possible.
So im looking for an alternative solution.
Thanks in Advance :-)
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

Hi. Welcome to The Ranch. But can you avoid posting the same message to more than one thread, please? Thanks.

Duplicate of http://www.coderanch.com/t/572591/JDBC/java/Dynamic-Database-Connection
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic Database Connection