0
点赞
收藏
分享

微信扫一扫

properties的读取及HSQL的学习(一)

Mhhao 2022-12-07 阅读 102

DB.properties

#HSQLDB Configer
HSQL_USERNAME=sa
HSQL_PASSWORD=
HSQL_DRIVERNAME=org.hsqldb.jdbcDriver
HSQL_URL=jdbc:hsqldb:hsql://localhost/test

ReadProperties.java

package org.test;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class ReadProperties {
public static Logger loggetLogger(ReadProperties.class);
static Properties p = null;

public ReadProperties() {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(
"DB.properties");
p = new Properties();
try {
// InputStream is = new BufferedInputStream(new
// FileInputStream("./src/DB.properties"));
p.load(is);
} catch (IOException e1) {
log.error(e1);
}

}
/**
*
*/
public static String[] getHSQLINFO() {
new ReadProperties();
String[] value = new String[4];
value[0] = p.getProperty("HSQL_USERNAME");
value[1] = p.getProperty("HSQL_PASSWORD");
value[2] = p.getProperty("HSQL_DRIVERNAME");
value[3] = p.getProperty("HSQL_URL");
return value;
}
/**
*
* 概述:
* @Title: getConnInfo
* @param userName
* @param passWord
* @param driverName
* @param url
* @return
* String[]
* @user <a href=mailto:linfenliang@126.com>linfenliang</a>
*/
public static String[] getConnInfo(String userName,String passWord,String driverName,String url){
new ReadProperties();
String[] value = new String[4];
value[0] = p.getProperty(userName);
value[1] = p.getProperty(passWord);
value[2] = p.getProperty(driverName);
value[3] = p.getProperty(url);
return value;
}
}

举报

相关推荐

0 条评论