Bookmark Topic Watch Topic
  • New Topic

Dynamic Database Connection

 
Jagadish Jain
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic