diff --git a/WebContent/WEB-INF/config/config.properties b/WebContent/WEB-INF/config/config.properties index 7381d79d..ed3ca5f6 100644 --- a/WebContent/WEB-INF/config/config.properties +++ b/WebContent/WEB-INF/config/config.properties @@ -4,7 +4,7 @@ # 驱动程序 jdbc.mysql.driver=com.mysql.jdbc.Driver # 连接url -jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/extend_glusterfs?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +jdbc.mysql.url=jdbc:mysql://192.168.0.110:3306/ftpdata?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true # 用户名 jdbc.mysql.username=root # 密码 @@ -46,11 +46,11 @@ gather-tablespace-name=TS_TTSSS gather-tablespace-path= gather-table-user-password= -kubeMasterUrl=http://192.168.191.23:8080/ +kubeMasterUrl=http://192.168.0.110:8080/ collect-user-name=system collect-password=oracle collect-service-name=orcl -gfs_control_ip=192.168.191.23 +gfs_control_ip=192.168.0.110 gfs_control_rootPassWd=root \ No newline at end of file diff --git a/src/com/platform/oracle/OracleConnector.java b/src/com/platform/oracle/OracleConnector.java index 923d578b..16f9d09a 100644 --- a/src/com/platform/oracle/OracleConnector.java +++ b/src/com/platform/oracle/OracleConnector.java @@ -8,6 +8,7 @@ import java.sql.Statement; import com.base.Custom4exception; import com.base.CustomException; +import com.platform.entities.OracleConnectorParams; import com.platform.utils.Configs; import com.platform.utils.FileOperateHelper; @@ -25,19 +26,23 @@ public class OracleConnector { public synchronized static Connection ConnectionBuilder(String url, String user, - String password) { + String password, OracleConnectorParams oc) { 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"); + } } return conn; } public synchronized static boolean canConnect(String url, String user, String password) { - return (null != ConnectionBuilder(url, user, password)); + return (null != ConnectionBuilder(url, user, password, null)); } public synchronized static ResultSet getSQLExecResultSet(Connection conn, String sql, String filePath) { @@ -60,7 +65,7 @@ public class OracleConnector { public synchronized static ResultSet getSQLExecResultSet(String url, String user, String password, String sql, String filePath) { - return getSQLExecResultSet(ConnectionBuilder(url, user, password), sql, filePath); + return getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath); } /** diff --git a/src/com/platform/service/OracleExtractService.java b/src/com/platform/service/OracleExtractService.java index 1b23ed7c..23df97ce 100644 --- a/src/com/platform/service/OracleExtractService.java +++ b/src/com/platform/service/OracleExtractService.java @@ -13,7 +13,7 @@ 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); + this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null); } @Override public void run() { diff --git a/src/com/platform/service/impl/OracleExtractServiceImpl.java b/src/com/platform/service/impl/OracleExtractServiceImpl.java index 908dc4c9..a53bef9b 100644 --- a/src/com/platform/service/impl/OracleExtractServiceImpl.java +++ b/src/com/platform/service/impl/OracleExtractServiceImpl.java @@ -19,6 +19,7 @@ import com.platform.service.IOracleExtractService; import com.platform.service.OracleExtractHelper; import com.platform.utils.Configs; import com.platform.utils.Constant; +import com.platform.utils.FileOperateHelper; @Service(value = "OracleExtract") public class OracleExtractServiceImpl implements IOracleExtractService { @@ -48,8 +49,16 @@ public class OracleExtractServiceImpl implements IOracleExtractService { GatherOracleInfo oracleModel = oracleConnect; //采集库连接参数 List datainfos = dataInfolist; + if (datainfos.size() == 0) { + return false; + } Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":" - + oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword()); + + oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(),dataInfolist.get(0)); + if (null == conn) { + FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION + + dataInfolist.get(0).getName(), "创建oracle连接失败: [" + conn + "]\r\n"); + return false; + } for (OracleConnectorParams collectOracle : datainfos) { if(null != collectOracle.getDataId() && !"".equals(collectOracle.getDataId())){ diff --git a/src/com/platform/utils/GanymedSSH.java b/src/com/platform/utils/GanymedSSH.java index a2fa59e3..e236ced5 100644 --- a/src/com/platform/utils/GanymedSSH.java +++ b/src/com/platform/utils/GanymedSSH.java @@ -145,7 +145,9 @@ public class GanymedSSH { // TODO Auto-generated catch block e.printStackTrace(); } finally { - sess.close(); + if (null != sess) { + sess.close(); + } } return reStrings;