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

📄 databaseinfodefault.java

📁 OA典型例子
💻 JAVA
字号:
package com.sure.dataabstraction;

import java.util.Properties;
import java.io.*;

/**
 *This is the default DatabaseInfo implemention privide databaseInfo by
 *Property like System property or file property.
 *
 *@author     Mengzy
 *@date       2002-8-16
 */
public class DatabaseInfoDefault implements DatabaseInfo {
    private String connectionClassName;
    private String driverName;
    private String driverURL;
    private String userName;
    private String password;
    private String logFileName;
    private int poolSize;
    private int initSize;
    private double lifecycle;

    private Properties property;

    private final static String CONFIG_FILE = "oc.conf";
    private final static String CONFIG_URI = "oc.path";


    /**
     *  Constructor for the DatabaseInfoDefault object
     */
    public DatabaseInfoDefault() {
	property = null;
	String path = System.getProperty(CONFIG_URI);
	String configFile;
	if (path == null) {
	    path = ".";
	}
	configFile = path + "/conf/" + CONFIG_FILE;
	File file = new File(configFile);
	if (!file.exists()) {
	    throw new RuntimeException(configFile + " file not found");
	}
	try {
	    property = new Properties();
	    property.load(new BufferedInputStream(new FileInputStream(file)));
	    connectionClassName = property.getProperty("ConnectionClassName");
	    driverName = property.getProperty("DriverName", "");
	    driverURL = property.getProperty("DriverURL", "");
	    logFileName = path + "/" + property.getProperty("DatabaseLogFile", "logs/Connection.log");
	    userName = property.getProperty("UserName", "");
	    password = property.getProperty("Password", "");
	    poolSize = Integer.parseInt(property.getProperty("PoolSize", "30"));
	    initSize = Integer.parseInt(property.getProperty("InitSize", "5"));
	    lifecycle = Double.parseDouble(property.getProperty("Lifecycle", "3000"));
	} catch (IOException ex) {
	    System.err.println(ex.getMessage());
	}
    }


    /**
     *@return    String
     */
    public String getDriverName() {
	return driverName;
    }


    /**
     *@return    String
     */
    public String getURL() {
	return driverURL;
    }


    /**
     *@return    String
     */
    public String getUserName() {
	return userName;
    }


    /**
     *@return    String
     */
    public String getPasswd() {
	return password;
    }


    /**
     *@param  name
     *@return       String
     */
    public String getProperty(String name) {
	return getProperty(name, null);
    }


    /**
     *@param  name
     *@param  defalut
     *@return          void
     */
    public String getProperty(String name, String defalut) {
	return property.getProperty(name, defalut);
    }


    /**
     *@return    int
     */
    public int getPoolSize() {
	return poolSize;
    }


    /**
     *  Gets the initSize attribute of the DatabaseInfoDefault object
     *
     *@return    The initSize value
     */
    public int getInitSize() {
	return initSize;
    }


    /**
     *@return    String
     */
    public String getConnectionPoolName() {
	return connectionClassName;
    }


    /**
     *  Gets the logName attribute of the DatabaseInfoDefault object
     *
     *@return    The logName value
     */
    public String getLogName() {
	return logFileName;
    }


    /**
     *  Gets the lifecycle attribute of the DatabaseInfoDefault object
     *
     *@return    The lifecycle value
     */
    public double getLifecycle() {
	return lifecycle;
    }

}

⌨️ 快捷键说明

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