Java Properties Load from File loadDBProperties(String dbConn)

Here you can find the source of loadDBProperties(String dbConn)

Description

Load a properties file describing the database properties for connecting to

License

Open Source License

Parameter

Parameter Description
dbConn the name of the properties file (in the class path)

Return

a loaded resource bundle

Declaration

public static Properties loadDBProperties(String dbConn) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class Main {
    /**//  w ww  .  j  a va 2  s . com
     * Load a properties file describing the database properties for connecting to
     * @param dbConn the name of the properties file (in the class path)
     * @return a loaded resource bundle
     */
    public static Properties loadDBProperties(String dbConn) {
        if (dbConn == null)
            return null;
        else {
            String wd = System.getProperty("user.dir");
            File wdDir = new File(wd);
            Properties props = new Properties();
            try {
                FileInputStream fis = new FileInputStream(wdDir + File.separator + dbConn + ".properties");
                props.load(fis);
                fis.close();
                return props;
            } catch (Exception e) {
                System.out.println(e.getMessage());
                return null;
            }
        }
    }
}

Related

  1. loadConfiguration()
  2. loadConfiguration(String file)
  3. loadConfiguration(String filePath)
  4. loadCredentials(File credentials, String credentialsAppend)
  5. loadCryptoProperties()
  6. loadDefault(String _file_path)
  7. loadDefaultConfiguration()
  8. loadDefaultProps(Properties deployProps)
  9. LoadDeployedObjects(String outputDirectory)