📄 dbconfigloader.java
字号:
package org.wap.util;
import java.util.Properties;
import java.sql.SQLException;
/**
* Created by IntelliJ IDEA.
* User: tyrones
* Date: 2003-8-8
* Time: 17:29:32
*
*/
public class DbConfigLoader {
private static String dsDriver = null;
private static String dsProtocol = null;
private static String dsSubprotocol = null;
private static String dsName = null;
private static String dsUsername = null;
private static String dsPassword = null;
private static String url = null;
private static String connectionType = null;
private static String jndiName = null;
public static void setDbConfigContext(String configFile, String source) throws SQLException, Exception {
try {
Properties prop = new Properties();
prop.load(DbConfigLoader.class.getResourceAsStream(configFile));
if (prop != null) {
dsDriver = prop.getProperty(source + ".driver");
dsProtocol = prop.getProperty(source + ".protocol");
dsSubprotocol = prop.getProperty(source + ".subprotocol");
if (dsName == null)
dsName = prop.getProperty(source + ".dsname");
if (dsUsername == null)
dsUsername = prop.getProperty(source + ".username");
if (dsPassword == null)
dsPassword = prop.getProperty(source + ".password");
if (connectionType == null)
connectionType = prop.getProperty(source + ".connectiontype");
if (jndiName == null)
jndiName = prop.getProperty(source + ".jndiname");
url = dsProtocol.trim() + ":" + dsSubprotocol.trim() + ":" + dsName.trim();
System.out.println(prop.toString());
} else {
throw new Exception("* Can not find property file '" + configFile);
}
} catch (ClassNotFoundException e) {
throw new Exception("* Can not find driver class '" + dsDriver + "'!");
}
}
public static String getDriver() {
return dsDriver.trim();
}
public static String getUrl() {
return url.trim();
}
public static String getUserName() {
return dsUsername.trim();
}
public static String getPassword() {
return dsPassword.trim();
}
public static String getConnectionType() {
return connectionType.trim();
}
public static String getJNDIName() {
return jndiName.trim();
}
/**
* @param string
*/
public static void setDsPassword(String string) {
dsPassword = string;
}
/**
* @param string
*/
public static void setDsUsername(String string) {
dsUsername = string;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -