I have a project in which I have been using a single database till now. Now there is a requirement to use a new database. I have one Dbconn java file in which I have hard-coded the database name, username, password like shown below:
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","pass");
Now my requirement is to have another connection to a new database so that I can access the data from it using the same connection object. In other words, I want to avoid hard coding this and I want a different way where I can accommodate more number of databases in future. Could anyone please let me know how I can proceed about this?
jdbc:mysql://localhost:3306/anotherdbor a completely different database instance iejdbc:mysql://someotherhost:3306/anotherdb?