Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jdbc.driverClassName = com.mysql.jdbc.Driver
- jdbc.url = jdbc:mysql://localhost:3306/testdb
- jdbc.username = root
- jdbc.password =
- //Default Constructor
- public DBManagerImpl(){
- JDBC_DRIVER = getResource().getProperty("jdbc.driverClassName","com.mysql.jdbc.Driver");
- try {
- Class.forName(JDBC_DRIVER);
- }...
- }
- //Getting properties file
- private Properties getResource(){
- Properties prop = new Properties();
- InputStream input = null;
- try {
- input = getClass().getClassLoader().getResourceAsStream("config.properties");
- prop.load(input);
- } ...
- return prop;
- }
- public Connection getConnection() {
- Connection connection = null;
- try {
- DATABASE_URL = getResource().getProperty("jdbc.url", "jdbc:mysql://localhost:3306/defaultdb");
- username = getResource().getProperty("jdbc.username", "root");
- password = getResource().getProperty("jdbc.password", "");
- connection = DriverManager.getConnection(DATABASE_URL, username, password);
- } ...
- return connection;
- }
Add Comment
Please, Sign In to add comment