OracleConnector类的ConnectionBuilder方法的异常抛出来

web_backend_develope
chenlw 9 years ago
parent c0c48fa89f
commit 58c349c24c

@ -26,23 +26,30 @@ public class OracleConnector {
public synchronized static Connection ConnectionBuilder(String url, String user,
String password, OracleConnectorParams oc) {
String password, OracleConnectorParams oc) throws CustomException {
Connection conn=null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
new CustomException(Custom4exception.OracleSQL_Except, e);
Configs.CONSOLE_LOGGER.info("创建oracle连接失败: [" + e.getMessage() + "]");
if (null != oc) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
}
throw new CustomException(Custom4exception.OracleSQL_Except, e);
}
return conn;
}
public synchronized static boolean canConnect(String url, String user, String password) {
return (null != ConnectionBuilder(url, user, password, null));
Connection result = null;
try {
result = ConnectionBuilder(url, user, password, null);
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (null != result);
}
public synchronized static ResultSet getSQLExecResultSet(Connection conn, String sql, String filePath) {
@ -65,7 +72,13 @@ public class OracleConnector {
public synchronized static ResultSet getSQLExecResultSet(String url, String user,
String password, String sql, String filePath) {
return getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath);
ResultSet result = null;
try {
result = getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath);
} catch (CustomException e) {
new CustomException(Custom4exception.OracleSQL_Except, e);
}
return result;
}
/**

@ -2,6 +2,7 @@ package com.platform.service;
import com.base.CustomException;
import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs;
@ -13,7 +14,11 @@ public class OracleExtractService extends Thread implements Runnable {
public OracleExtractService(OracleConnectorParams ocp){
this.ocp=ocp;
String url = "";
this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
try {
this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
} catch (CustomException e) {
this.conn = null;
}
}
@Override
public void run() {

Loading…
Cancel
Save