?? jdbcdatasrc.java.svn-base
字號:
package com.nsi.persistence;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.nsi.util.settings.SystemSettings;
public class JdbcDataSrc extends DataSrcImpl
{
public JdbcDataSrc()
{
}
/**
* @see com.nsi.persistence.IsqlDataSource#getConnection()
*/
public Connection getConnection() throws Exception, SQLException
{
String drivername = SystemSettings.getInstance().getDrcDriver();
String dburl = SystemSettings.getInstance().getDrcURL();
String dbuid = SystemSettings.getInstance().getDrcUID();
String dbpwd = SystemSettings.getInstance().getDrcPWD();
try
{
Class.forName(drivername);
return DriverManager.getConnection(dburl, dbuid, dbpwd);
}
catch (ClassNotFoundException cnfEx)
{
throw new SQLException(drivername + " : class not found \r\n" + cnfEx.getMessage());
}
}
/**
* @see com.nsi.persistence.IsqlDataSource#getConnection()
*/
public Connection getConnection(String dbType) throws Exception, SQLException
{
String drivername="";
String dburl="";
String dbuid="";
String dbpwd="";
if("POSTGRE".equalsIgnoreCase(dbType))
{
drivername = SystemSettings.getInstance().getDrcDriver();
dburl = SystemSettings.getInstance().getDrcURL();
dbuid = SystemSettings.getInstance().getDrcUID();
dbpwd = SystemSettings.getInstance().getDrcPWD();
}
if("MSSQL".equalsIgnoreCase(dbType))
{
drivername = SystemSettings.getInstance().getJDBCSQLDriver();
dburl = SystemSettings.getInstance().getJDBCForSQLServerUrl();
dbuid = SystemSettings.getInstance().getSQLSUID();
dbpwd = SystemSettings.getInstance().getSQLSPWD();
}
try
{
Class.forName(drivername);
return DriverManager.getConnection(dburl, dbuid, dbpwd);
}
catch (ClassNotFoundException cnfEx)
{
throw new SQLException(drivername + " : class not found \r\n" + cnfEx.getMessage());
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -