标签:src jdb return ext sele ret tab gets color
var srcDs="zjkvta"; var destDs = "loadgsdw"; function main(args) { copyData(srcDs, "F_ZJLRLC", destDs, "TEST_F_ZJLRLC"); } /** * * @param srcDs 源数据所在数据源名 * @param srcTableName 查询源数据SQL * @param destDs 转换的数据 * @param destTableName 转换的目的表数据 */ function copyData(srcDs, srcTableName, destDs, destTableName){ var logfile = sz.sys.getWorkDir() + "/log.txt"; println("开始抽取:"+srcTableName); var ds = sz.db.getDataSource(srcDs); var conn = ds.getConnection(); try { var stmt = conn.createStatement(); try { var ss = (new Date()).getTime(); var rs = stmt.executeQuery("select * from "+srcTableName); try{ var rowCount = loadTable(rs, destDs, destTableName); var ee = (new Date()).getTime(); var info = "耗时 " + (ee - ss); println("抽取完成:"+srcTableName+info+",迁移行数:"+rowCount); }finally{ rs.close(); } } finally { stmt.close(); } } finally { conn.close(); } } /** * */ function loadTable(srcResultSet, destDataSource, destTableName) { var ds = sz.db.getDataSource(destDataSource); try { var conn = ds.getConnection(); var realConn = conn.getSourceConnection().getConnection(); var bulkLoader = com.ddtek.jdbc.extensions.DDBulkLoadFactory.getInstance(realConn); try { bulkLoader.setTableName(destTableName); return bulkLoader.load(srcResultSet); } finally { bulkLoader.close(); } } finally { conn.close(); } }
标签:src jdb return ext sele ret tab gets color
原文地址:https://www.cnblogs.com/sorliran/p/9282137.html