package common; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; /** * @author n-sasaki */ public class DatabaseProperties extends Properties { private DatabaseProperties() throws Exception { loadProperties(PROPERTY_FILE_NAME); } private DatabaseProperties(String propertiesFilePath) throws Exception { loadProperties(propertiesFilePath); } public synchronized static DatabaseProperties create() throws Exception { if (testProoerties == null) testProoerties = new DatabaseProperties(); return testProoerties; } public synchronized static DatabaseProperties create(String propertiesFilePath) throws Exception { if (testProoerties == null) testProoerties = new DatabaseProperties(propertiesFilePath); return testProoerties; } public String getDriverClassName() { return getProperty("driverClass", "oracle.jdbc.driver.OracleDriver"); } public String getDatabaseUrl() { return getProperty("database.Url", "jdbc:oracle:thin:@localhost:1521:PCS"); } public String getDatabaseUserName() { return getProperty("database.userName", ""); } public String getDatabasePassword() { return getProperty("database.password", ""); } public String getDatabaseSchema() { return getProperty("database.schema", ""); } public String getTestDataDirectory() { return getProperty("testData.directory", ""); } protected void loadProperties(String fileName) throws Exception { InputStream is = ClassLoader.getSystemResourceAsStream(fileName); if (is == null) { is = new FileInputStream(fileName); } load(is); } private static final String PROPERTY_FILE_NAME = "TestData.properties"; private static DatabaseProperties testProoerties; }