Hi all following is my database connection file,
package org.slingemp.common;
import java.sql.Connection;
import java.sql.DriverManager;
public class JDBCManager {
public Connection mysqlConnection() {
Connection dbConnection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
dbConnection=DriverManager.getConnection("jdbc:mysql://localhost:3306/slingemp","root","root");
//System.out.println("mysql Driver Connedted::::::::");
} catch (Exception e) {
e.printStackTrace();
}
return dbConnection;
}
}
in this i want to make connection string and driver name configurable. how to do this and where to put the file which contains configurable values?
Regards
Tony
You can put them into
.propertiesfile or server JNDI resources.jdbc.properties example:
Then in java class use this to get properties:
But more efficient way would be to use JNDI.