⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loadprop.java

📁 JSP新闻发布系统 JSP新闻发布系统
💻 JAVA
字号:
package net.ijsp.news.database;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: ijsp.net</p> * @author ccjsmile * @version 1.0 */import java.io.*;import java.sql.*;import java.util.*;import java.util.Date;public class LoadProp {private	String driver,url,user,password,logfile;private	int minconn=0,maxconn=0,debug=0;private	String poolName;private	int maxconntime=0;private String indexPath;private static LoadProp prop;private static Object lock = new Object();public LoadProp() {}public static void main(String[] args) {LoadProp lp = new LoadProp();lp.prop();}/*** 获取基本配置*/public LoadProp prop() {        System.out.println("读取配置文件信息");        if (prop == null) {       synchronized (lock) {         if (prop == null)              prop = init1();         }    }        return  prop;}/*** 清除静态信息*/public void reSet() {        this.prop = null;}/*** 设置基本信息*/public void setDriver(String driver) {        this.driver = driver;}public void setUrl(String url) {        this.url = url;}public void setUser(String user) {        this.user = user;}public void setPassword(String password) {        this.password = password;}public void setLogfile(String logfile) {        this.logfile = logfile;}public void setMinconn(int minconn) {        this.minconn = minconn;}public void setMaxconn(int maxconn) {        this.maxconn = maxconn;}public void setDebug(int debug) {        this.debug = debug;}public void setMaxconntime(int maxconntime) {        this.maxconntime = maxconntime;}public String getDriver() {        return driver;}public String getUrl() {        return url;}public String getUser() {        return user;}public String getPassword() {        return password;}public String getLogfile() {        return logfile;}public int getMinconn() {        return minconn;}public int getMaxconn() {        return maxconn;}public int getDebug() {        return debug;}public int getMaxconntime() {        return maxconntime;}/*** 索引文件地址*/public void setIndexPath(String indexPath) {        this.indexPath = indexPath;}public String getIndexPath() {        return indexPath;}/*** 获取基本配置信息*/private synchronized LoadProp init1() {        if(prop==null) {                LoadProp lp = new LoadProp();                /**                * 打开配置信息文件                */                InputStream is = getClass().getResourceAsStream("/downloaddb.txt");                Properties props = new Properties();                try {                    props.load(is);                }catch (Exception e) {                    System.err.println("不能读取属性文件. 请确保downloaddb.txt在classes指定的路径中");                }                Enumeration propNames = props.propertyNames();                while (propNames.hasMoreElements()) {                        String name = (String) propNames.nextElement();                        if (name.endsWith(".driver")) {                                poolName = name.substring(0, name.lastIndexOf("."));                                lp.setDriver(props.getProperty(poolName + ".driver"));                                lp.setUrl(props.getProperty(poolName + ".url"));                                lp.setUser(props.getProperty(poolName + ".user"));                                lp.setPassword(props.getProperty(poolName + ".password"));                                lp.setLogfile(props.getProperty(poolName + ".logfile"));                                lp.setMinconn(Integer.parseInt(props.getProperty(poolName + ".minconn")));                                lp.setMaxconn(Integer.parseInt(props.getProperty(poolName + ".maxconn")));                                lp.setMaxconntime(Integer.parseInt(props.getProperty(poolName + ".maxconntime")));                                lp.setDebug(Integer.parseInt(props.getProperty(poolName + ".debug")));                }                lp.setIndexPath(props.getProperty("index.path"));        }                return lp;        }else{                return prop;        }}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -