日期:2014-05-16  浏览次数:20502 次

JDBC公共操作方法(三):记录数据库连接属性

记录数据库连接属性

?

import org.apache.log4j.Logger;

/**
 * @ClassName: LogJDBCProperties
 * @Description: 记录工程日志
 * @author
 * @date 2011-12-29 上午10:56:20
 * @version V1.0
 */
public final class LogJDBCProperties {

	private static final Logger LOG = Logger.getLogger(LogJDBCProperties.class);

	private static final LogJDBCProperties instance = new LogJDBCProperties();
	
	private LogJDBCProperties() {
	}
	
	public static LogJDBCProperties getInstance(){
		return instance;
	}

	/**
	 * @Title: logConnectionProperty  
	 * @Description: 记录数据库连接属性
	 * @param driverClass
	 * @param url
	 * @param user
	 * @param password  
	 * @author  
	 * @date 2011-12-29
	 */
	public void logConnectionProperty(String driverClass,String url,
			String user,String password){
		
		StringBuffer buf = new StringBuffer(10);
		
		buf.append("driverClass=").append(driverClass).append("\n");
		buf.append("url=").append(url).append("\n");
		buf.append("user=").append(user).append("\n");
		buf.append("password=").append(password).append("\n");
		
		LOG.info(buf);
	}
}
?