`
DataBird
  • 浏览: 71730 次
  • 性别: Icon_minigender_1
  • 来自: 湖南长沙
社区版块
存档分类
最新评论

数据收集示例01:ZTEoracle10g->MYDBoracle11g

阅读更多
关注内容:pstmt.setTimestamp(1, rs.getTimestamp(1));  //COLLECTTIME DATE


package datatransfer.zte;

import datatransfer.DB_ConnectManager;
import datatransfer.Main;
import java.sql.*;
import java.sql.PreparedStatement;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class STAT_ZTE_CELL extends Thread {

    String COLLECTTIME;
    String OMC;
    Connection connOMC;
    Connection connMyDB;
    Statement stmt;
    ResultSet rs;
    PreparedStatement pstmt;
    int wrong_cgi = 0;

    //初始化的方法必须申明为 public ,其它包才能访问
    public STAT_ZTE_CELL(String COLLECTTIME, String OMC) {
        this.COLLECTTIME = COLLECTTIME;
        this.OMC = OMC;
        try {
            connOMC = Main.StringMapOracleDS.get(OMC).getConnection();
            connMyDB = Main.WYDB.getConnection();
        } catch (SQLException ex) {
            Logger.getLogger(STAT_ZTE_CELL.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Override
    public void run() {
        //System.out.println(OMC + ":" + ENUMSQL_MOT_PM.STAT_MOT_CELL.SqlDataSource(fragment_date));
        try {
            long startTime = System.currentTimeMillis();
            pstmt = connMyDB.prepareStatement(ENUMSQL_ZTE_PM.STAT_ZTE_CELL.SqlMyDB(""));//INSERT INTO G_ZTE_620_CELL
            stmt = connOMC.createStatement();//SELECT FROM A_BASIC_CS_RADIO
            rs = stmt.executeQuery(ENUMSQL_ZTE_PM.STAT_ZTE_CELL.SqlDataSource(COLLECTTIME));
            int i = 0;
            String s = null;
            while (rs.next()) {
                i++;
                try {
//KPI,复制粘贴 《WYDB表结构.XLS》“JAVA结果集转移语句”
pstmt.setTimestamp(1, rs.getTimestamp(1));  //COLLECTTIME DATE
pstmt.setInt(2, rs.getInt(2));  //BSCID NUMBER(6)
pstmt.setInt(3, rs.getInt(3));  //SITEID NUMBER(6)
pstmt.setInt(4, rs.getInt(4));  //BTSID NUMBER(6)
pstmt.setInt(5, rs.getInt(5));  //C100030001 NUMBER(10),
pstmt.setInt(6, rs.getInt(6));  //C100030002 NUMBER(10),
pstmt.setInt(7, rs.getInt(7));  //C100030003 NUMBER(10),
pstmt.setInt(8, rs.getInt(8));  //C100030004 NUMBER(10),
pstmt.setInt(9, rs.getInt(9));  //C100030005 NUMBER(10),
pstmt.setInt(10, rs.getInt(10));  //C100030006 NUMBER(10),
pstmt.setInt(11, rs.getInt(11));  //C100030007 NUMBER(10),
pstmt.setInt(12, rs.getInt(12));  //C100030008 NUMBER(10),
pstmt.setInt(13, rs.getInt(13));  //C100030009 NUMBER(10),
pstmt.setInt(14, rs.getInt(14));  //C100030010 NUMBER(10),
pstmt.setInt(15, rs.getInt(15));  //C100030011 NUMBER(10),
pstmt.setInt(16, rs.getInt(16));  //C100030012 NUMBER(10),
pstmt.setInt(17, rs.getInt(17));  //C100030013 NUMBER(10),
pstmt.setInt(18, rs.getInt(18));  //C100030014 NUMBER(10),
pstmt.setInt(19, rs.getInt(19));  //C100030015 NUMBER(10),
pstmt.setInt(20, rs.getInt(20));  //C100030016 NUMBER(10),
pstmt.setInt(21, rs.getInt(21));  //C100030017 NUMBER(10),
pstmt.setInt(22, rs.getInt(22));  //C100030018 NUMBER(10),
pstmt.setInt(23, rs.getInt(23));  //C100030019 NUMBER(10),
pstmt.setInt(24, rs.getInt(24));  //C100030020 NUMBER(10),
pstmt.setInt(25, rs.getInt(25));  //C100030021 NUMBER(10),
pstmt.setInt(26, rs.getInt(26));  //C100030022 NUMBER(10),
pstmt.setInt(27, rs.getInt(27));  //C100030023 NUMBER(10),
pstmt.setInt(28, rs.getInt(28));  //C100030024 NUMBER(10),
pstmt.setInt(29, rs.getInt(29));  //C100030025 NUMBER(10),
pstmt.setInt(30, rs.getInt(30));  //C100030026 NUMBER(10),
pstmt.setInt(31, rs.getInt(31));  //C100030027 NUMBER(10),
pstmt.setInt(32, rs.getInt(32));  //C100030028 NUMBER(10),
pstmt.setInt(33, rs.getInt(33));  //C100030029 NUMBER(10),
pstmt.setInt(34, rs.getInt(34));  //C100030030 NUMBER(10),
pstmt.setInt(35, rs.getInt(35));  //C100030031 NUMBER(10),
pstmt.setInt(36, rs.getInt(36));  //C100030032 NUMBER(10),
pstmt.setInt(37, rs.getInt(37));  //C100030033 NUMBER(10),
pstmt.setInt(38, rs.getInt(38));  //C100030034 NUMBER(10),
pstmt.setInt(39, rs.getInt(39));  //C100030035 NUMBER(10),
pstmt.setInt(40, rs.getInt(40));  //C100030036 NUMBER(10),
pstmt.setInt(41, rs.getInt(41));  //C100030037 NUMBER(10),
pstmt.setInt(42, rs.getInt(42));  //C100030038 NUMBER(10),
pstmt.setInt(43, rs.getInt(43));  //C100030039 NUMBER(10),
pstmt.setInt(44, rs.getInt(44));  //C100030040 NUMBER(10),
pstmt.setInt(45, rs.getInt(45));  //C100030041 NUMBER(10),
pstmt.setInt(46, rs.getInt(46));  //C100030042 NUMBER(10),
pstmt.setInt(47, rs.getInt(47));  //C100030043 NUMBER(10),
pstmt.setInt(48, rs.getInt(48));  //C100030044 NUMBER(10),
pstmt.setInt(49, rs.getInt(49));  //C100030045 NUMBER(10),
pstmt.setInt(50, rs.getInt(50));  //C100030046 NUMBER(10),
pstmt.setInt(51, rs.getInt(51));  //C100030047 NUMBER(10),
pstmt.setInt(52, rs.getInt(52));  //C100030048 NUMBER(10),
pstmt.setInt(53, rs.getInt(53));  //C100030049 NUMBER(10),
pstmt.setInt(54, rs.getInt(54));  //C100030050 NUMBER(10),
pstmt.setInt(55, rs.getInt(55));  //C100030051 NUMBER(10),
pstmt.setInt(56, rs.getInt(56));  //C100030052 NUMBER(10),
pstmt.setInt(57, rs.getInt(57));  //C100030053 NUMBER(10),
pstmt.setInt(58, rs.getInt(58));  //C100030054 NUMBER(10),
pstmt.setInt(59, rs.getInt(59));  //C100030055 NUMBER(10),
pstmt.setInt(60, rs.getInt(60));  //C100030056 NUMBER(10),
pstmt.setInt(61, rs.getInt(61));  //C100030057 NUMBER(10),
pstmt.setInt(62, rs.getInt(62));  //C100030058 NUMBER(10),
pstmt.setInt(63, rs.getInt(63));  //C100030059 NUMBER(10),
pstmt.setInt(64, rs.getInt(64));  //C100030060 NUMBER(10),
pstmt.setInt(65, rs.getInt(65));  //C100030061 NUMBER(10),
pstmt.setInt(66, rs.getInt(66));  //C100030062 NUMBER(10),
pstmt.setInt(67, rs.getInt(67));  //C100030063 NUMBER(10),
pstmt.setInt(68, rs.getInt(68));  //C100030064 NUMBER(10),
pstmt.setInt(69, rs.getInt(69));  //C100030065 NUMBER(10),
pstmt.setInt(70, rs.getInt(70));  //C100030066 NUMBER(10),
pstmt.setInt(71, rs.getInt(71));  //C100030067 NUMBER(10),
pstmt.setInt(72, rs.getInt(72));  //C100030068 NUMBER(10),
pstmt.setInt(73, rs.getInt(73));  //C100030069 NUMBER(10),
pstmt.setInt(74, rs.getInt(74));  //C100030070 NUMBER(10),
pstmt.setInt(75, rs.getInt(75));  //C100030071 NUMBER(10),
pstmt.setInt(76, rs.getInt(76));  //C100030072 NUMBER(10),
pstmt.setInt(77, rs.getInt(77));  //C100030073 NUMBER(10),
pstmt.setInt(78, rs.getInt(78));  //C100030074 NUMBER(10),
pstmt.setInt(79, rs.getInt(79));  //C100030075 NUMBER(10),
pstmt.setInt(80, rs.getInt(80));  //C100030076 NUMBER(10),
pstmt.setInt(81, rs.getInt(81));  //C100030077 NUMBER(10),
pstmt.setInt(82, rs.getInt(82));  //C100030078 NUMBER(10),
pstmt.setInt(83, rs.getInt(83));  //C100030079 NUMBER(10),
pstmt.setInt(84, rs.getInt(84));  //C100030080 NUMBER(10),
pstmt.setInt(85, rs.getInt(85));  //C100030081 NUMBER(10),
pstmt.setInt(86, rs.getInt(86));  //C100030082 NUMBER(10),
pstmt.setInt(87, rs.getInt(87));  //C100030083 NUMBER(10),
pstmt.setInt(88, rs.getInt(88));  //C100030084 NUMBER(10),
pstmt.setInt(89, rs.getInt(89));  //C100030085 NUMBER(10),
pstmt.setInt(90, rs.getInt(90));  //C100030086 NUMBER(10),
pstmt.setInt(91, rs.getInt(91));  //C100030087 NUMBER(10),
pstmt.setInt(92, rs.getInt(92));  //C100030088 NUMBER(10),
pstmt.setInt(93, rs.getInt(93));  //C100030089 NUMBER(10),
pstmt.setInt(94, rs.getInt(94));  //C100030090 NUMBER(10),
pstmt.setInt(95, rs.getInt(95));  //C100030091 NUMBER(10),
pstmt.setInt(96, rs.getInt(96));  //C100030092 NUMBER(10),
pstmt.setInt(97, rs.getInt(97));  //C100030093 NUMBER(10),
pstmt.setInt(98, rs.getInt(98));  //C100030094 NUMBER(10),
pstmt.setInt(99, rs.getInt(99));  //C100030095 NUMBER(10),
pstmt.setInt(100, rs.getInt(100));  //C100030096 NUMBER(10),
pstmt.setInt(101, rs.getInt(101));  //C100030097 NUMBER(10),
pstmt.setInt(102, rs.getInt(102));  //C100030098 NUMBER(10),
pstmt.setInt(103, rs.getInt(103));  //C100030099 NUMBER(10),
pstmt.setInt(104, rs.getInt(104));  //C100030100 NUMBER(10),
pstmt.setInt(105, rs.getInt(105));  //C100030101 NUMBER(10),
pstmt.setInt(106, rs.getInt(106));  //C100030102 NUMBER(10),
pstmt.setInt(107, rs.getInt(107));  //C100030103 NUMBER(10),
pstmt.setInt(108, rs.getInt(108));  //C100030104 NUMBER(10),
pstmt.setInt(109, rs.getInt(109));  //C100030105 NUMBER(10),
pstmt.setInt(110, rs.getInt(110));  //C100030106 NUMBER(10),
pstmt.setInt(111, rs.getInt(111));  //C100030107 NUMBER(10),
pstmt.setInt(112, rs.getInt(112));  //C100030108 NUMBER(10),
pstmt.setInt(113, rs.getInt(113));  //C100030109 NUMBER(10),
pstmt.setInt(114, rs.getInt(114));  //C100030110 NUMBER(10),
pstmt.setInt(115, rs.getInt(115));  //C100030111 NUMBER(10),
pstmt.setInt(116, rs.getInt(116));  //C100030112 NUMBER(10),
pstmt.setInt(117, rs.getInt(117));  //C100030113 NUMBER(10),
pstmt.setInt(118, rs.getInt(118));  //C100030114 NUMBER(10),
pstmt.setInt(119, rs.getInt(119));  //C100030115 NUMBER(10),
pstmt.setInt(120, rs.getInt(120));  //C100030116 NUMBER(10),
pstmt.setInt(121, rs.getInt(121));  //C100030117 NUMBER(10),
pstmt.setInt(122, rs.getInt(122));  //C100030118 NUMBER(10),
pstmt.setInt(123, rs.getInt(123));  //C100030119 NUMBER(10),
pstmt.setInt(124, rs.getInt(124));  //C100030120 NUMBER(10),
pstmt.setInt(125, rs.getInt(125));  //C100030121 NUMBER(10),
pstmt.setInt(126, rs.getInt(126));  //C100030122 NUMBER(10),
pstmt.setInt(127, rs.getInt(127));  //C100030123 NUMBER(10),
pstmt.setInt(128, rs.getInt(128));  //C100030124 NUMBER(10),
pstmt.setInt(129, rs.getInt(129));  //C100030125 NUMBER(10),
pstmt.setInt(130, rs.getInt(130));  //C100030126 NUMBER(10),
pstmt.setInt(131, rs.getInt(131));  //C100030127 NUMBER(10),
pstmt.setInt(132, rs.getInt(132));  //C100030128 NUMBER(10),
pstmt.setInt(133, rs.getInt(133));  //C100030129 NUMBER(10),
pstmt.setInt(134, rs.getInt(134));  //C100030130 NUMBER(10),
pstmt.setInt(135, rs.getInt(135));  //C100030131 NUMBER(10),
pstmt.setInt(136, rs.getInt(136));  //C100030132 NUMBER(10),
pstmt.setInt(137, rs.getInt(137));  //C100030133 NUMBER(10),
pstmt.setInt(138, rs.getInt(138));  //C100030134 NUMBER(10),
pstmt.setInt(139, rs.getInt(139));  //C100030135 NUMBER(10),
pstmt.setInt(140, rs.getInt(140));  //C100030136 NUMBER(10),
pstmt.setInt(141, rs.getInt(141));  //C100030137 NUMBER(10),
pstmt.setInt(142, rs.getInt(142));  //C100030138 NUMBER(10),
pstmt.setInt(143, rs.getInt(143));  //C100030139 NUMBER(10),
pstmt.setInt(144, rs.getInt(144));  //C100030140 NUMBER(10),
pstmt.setInt(145, rs.getInt(145));  //C100030141 NUMBER(10),
pstmt.setInt(146, rs.getInt(146));  //C100030142 NUMBER(10),
pstmt.setInt(147, rs.getInt(147));  //C100030143 NUMBER(10),
pstmt.setInt(148, rs.getInt(148));  //C100030144 NUMBER(10),
pstmt.setInt(149, rs.getInt(149));  //C100030145 NUMBER(10),
pstmt.setInt(150, rs.getInt(150));  //C100030146 NUMBER(10),
pstmt.setInt(151, rs.getInt(151));  //C100030147 NUMBER(10),
pstmt.setInt(152, rs.getInt(152));  //C100030148 NUMBER(10),
pstmt.setInt(153, rs.getInt(153));  //C100030149 NUMBER(10),
pstmt.setInt(154, rs.getInt(154));  //C100030150 NUMBER(10),
pstmt.setInt(155, rs.getInt(155));  //C100030151 NUMBER(10),
pstmt.setInt(156, rs.getInt(156));  //C100030152 NUMBER(10),
pstmt.setInt(157, rs.getInt(157));  //C100030153 NUMBER(10),
pstmt.setInt(158, rs.getInt(158));  //C100030154 NUMBER(10),
pstmt.setInt(159, rs.getInt(159));  //C100030155 NUMBER(10),
pstmt.setInt(160, rs.getInt(160));  //C100030156 NUMBER(10),
pstmt.setInt(161, rs.getInt(161));  //C100030157 NUMBER(10),
pstmt.setInt(162, rs.getInt(162));  //C100030158 NUMBER(10),
pstmt.setInt(163, rs.getInt(163));  //C100030159 NUMBER(10),
pstmt.setInt(164, rs.getInt(164));  //C100030160 NUMBER(10),
pstmt.setInt(165, rs.getInt(165));  //C100030161 NUMBER(10),
pstmt.setInt(166, rs.getInt(166));  //C100030162 NUMBER(10),
pstmt.setInt(167, rs.getInt(167));  //C100030163 NUMBER(10),
pstmt.setInt(168, rs.getInt(168));  //C100030164 NUMBER(10),
pstmt.setInt(169, rs.getInt(169));  //C100030165 NUMBER(10),
pstmt.setInt(170, rs.getInt(170));  //C100030166 NUMBER(10),
pstmt.setInt(171, rs.getInt(171));  //C100030167 NUMBER(10),
pstmt.setInt(172, rs.getInt(172));  //C100030168 NUMBER(10),
pstmt.setInt(173, rs.getInt(173));  //C100030169 NUMBER(10),
pstmt.setInt(174, rs.getInt(174));  //C100030170 NUMBER(10),
pstmt.setInt(175, rs.getInt(175));  //C100030171 NUMBER(10),
pstmt.setInt(176, rs.getInt(176));  //C100030172 NUMBER(10),
pstmt.setInt(177, rs.getInt(177));  //C100030173 NUMBER(10),
pstmt.setInt(178, rs.getInt(178));  //C100030174 NUMBER(10),
pstmt.setInt(179, rs.getInt(179));  //C100030175 NUMBER(10),
pstmt.setInt(180, rs.getInt(180));  //C100030176 NUMBER(10),
pstmt.setInt(181, rs.getInt(181));  //C100030177 NUMBER(10),
pstmt.setInt(182, rs.getInt(182));  //C100030178 NUMBER(10),
pstmt.setInt(183, rs.getInt(183));  //C100030179 NUMBER(10),
pstmt.setInt(184, rs.getInt(184));  //C100030180 NUMBER(10),
pstmt.setInt(185, rs.getInt(185));  //C100030181 NUMBER(10),
pstmt.setInt(186, rs.getInt(186));  //C100030182 NUMBER(10),
pstmt.setInt(187, rs.getInt(187));  //C100030183 NUMBER(10),
pstmt.setInt(188, rs.getInt(188));  //C100030184 NUMBER(10),
pstmt.setInt(189, rs.getInt(189));  //C100030185 NUMBER(10),
pstmt.setInt(190, rs.getInt(190));  //C100030186 NUMBER(10),
pstmt.setInt(191, rs.getInt(191));  //C100030187 NUMBER(10),
pstmt.setInt(192, rs.getInt(192));  //C100030188 NUMBER(10),
pstmt.setInt(193, rs.getInt(193));  //C100030189 NUMBER(10),
pstmt.setInt(194, rs.getInt(194));  //C100030190 NUMBER(10),
pstmt.setInt(195, rs.getInt(195));  //C100030191 NUMBER(10),
pstmt.setInt(196, rs.getInt(196));  //C100030192 NUMBER(10),
pstmt.setInt(197, rs.getInt(197));  //C100030193 NUMBER(10),
pstmt.setInt(198, rs.getInt(198));  //C100030194 NUMBER(10),
pstmt.setInt(199, rs.getInt(199));  //C100030195 NUMBER(10),
pstmt.setInt(200, rs.getInt(200));  //C100030196 NUMBER(10),
pstmt.setInt(201, rs.getInt(201));  //C100030197 NUMBER(10),
pstmt.setInt(202, rs.getInt(202));  //C100030198 NUMBER(10),
pstmt.setInt(203, rs.getInt(203));  //C100030199 NUMBER(10),
pstmt.setInt(204, rs.getInt(204));  //C100030200 NUMBER(10),
pstmt.setInt(205, rs.getInt(205));  //C100030201 NUMBER(10),
pstmt.setInt(206, rs.getInt(206));  //C100030202 NUMBER(10),
pstmt.setInt(207, rs.getInt(207));  //C100030203 NUMBER(10),
pstmt.setInt(208, rs.getInt(208));  //C100030204 NUMBER(10),
pstmt.setInt(209, rs.getInt(209));  //C100030205 NUMBER(10),
pstmt.setInt(210, rs.getInt(210));  //C100030206 NUMBER(10),
pstmt.setInt(211, rs.getInt(211));  //C100030207 NUMBER(10),
pstmt.setInt(212, rs.getInt(212));  //C100030208 NUMBER(10),
pstmt.setInt(213, rs.getInt(213));  //C100030209 NUMBER(10),
pstmt.setInt(214, rs.getInt(214));  //C100030210 NUMBER(10),
pstmt.setInt(215, rs.getInt(215));  //C100030211 NUMBER(10),
pstmt.setInt(216, rs.getInt(216));  //C100030212 NUMBER(10),
pstmt.setInt(217, rs.getInt(217));  //C100030213 NUMBER(10),
pstmt.setInt(218, rs.getInt(218));  //C100030214 NUMBER(10),
pstmt.setInt(219, rs.getInt(219));  //C100030215 NUMBER(10),
pstmt.setInt(220, rs.getInt(220));  //C100030216 NUMBER(10),
pstmt.setInt(221, rs.getInt(221));  //C100030217 NUMBER(10),
pstmt.setInt(222, rs.getInt(222));  //C100030218 NUMBER(10),
pstmt.setInt(223, rs.getInt(223));  //C100030219 NUMBER(10),
pstmt.setInt(224, rs.getInt(224));  //C100030220 NUMBER(10),
pstmt.setInt(225, rs.getInt(225));  //C100030221 NUMBER(10),
pstmt.setInt(226, rs.getInt(226));  //C100030222 NUMBER(10),
pstmt.setInt(227, rs.getInt(227));  //C100030223 NUMBER(10),
pstmt.setInt(228, rs.getInt(228));  //C100030224 NUMBER(10),
pstmt.setInt(229, rs.getInt(229));  //C100030225 NUMBER(10),
pstmt.setInt(230, rs.getInt(230));  //C100030226 NUMBER(10),
pstmt.setInt(231, rs.getInt(231));  //C100030227 NUMBER(10),
pstmt.setInt(232, rs.getInt(232));  //C100030228 NUMBER(10),
pstmt.setInt(233, rs.getInt(233));  //C100030229 NUMBER(10),
pstmt.setInt(234, rs.getInt(234));  //C100030230 NUMBER(10),
pstmt.setInt(235, rs.getInt(235));  //C100030231 NUMBER(10),
pstmt.setInt(236, rs.getInt(236));  //C100030232 NUMBER(10),
pstmt.setInt(237, rs.getInt(237));  //C100030233 NUMBER(10),
pstmt.setInt(238, rs.getInt(238));  //C100030234 NUMBER(10),
pstmt.setInt(239, rs.getInt(239));  //C100030235 NUMBER(10),
pstmt.setInt(240, rs.getInt(240));  //C100030236 NUMBER(10),
pstmt.setInt(241, rs.getInt(241));  //C100030237 NUMBER(10),
pstmt.setInt(242, rs.getInt(242));  //C100030238 NUMBER(10),
pstmt.setInt(243, rs.getInt(243));  //C100030239 NUMBER(10),
pstmt.setInt(244, rs.getInt(244));  //C100030240 NUMBER(10),
pstmt.setInt(245, rs.getInt(245));  //C100030241 NUMBER(10),
pstmt.setInt(246, rs.getInt(246));  //C100030242 NUMBER(10),
pstmt.setInt(247, rs.getInt(247));  //C100030243 NUMBER(10),
pstmt.setInt(248, rs.getInt(248));  //C100030244 NUMBER(10),
pstmt.setInt(249, rs.getInt(249));  //C100030245 NUMBER(10)
//KPI,复制粘贴 《WYDB表结构.XLS》“JAVA结果集转移语句”

                    pstmt.addBatch();

                    //提交点检查
                    if (i % 1000 == 0) {
                        pstmt.executeBatch();
                        connMyDB.commit();
//                        System.out.println(OMC + "===1000提交量===" + i);
                    }

                } catch (NumberFormatException e) {
                    System.out.println(rs + ":本条记录格式存在错误,扔掉" + s + ">>共计错误CGI:" + ++wrong_cgi);
                }
            } //while over
            // Execute the batch
            int[] updateCounts = pstmt.executeBatch();
            // All statements were successfully executed.
            // updateCounts contains one element for each batched statement.
            // updateCounts[i] contains the number of rows affected by that statement.
            processUpdateCounts(updateCounts);
            // Since there were no errors, commit
            connMyDB.commit();
            System.out.println(OMC + "/" + ENUMSQL_ZTE_PM.STAT_ZTE_CELL.getTableName() + "数据导入完成" + i + "条记录。");
            long endTime = System.currentTimeMillis();
            System.out.println("采集耗时:" + (endTime - startTime) / 1000 + "秒");

            //写记账薄 SELECT * FROM CSUDF_SYS_IMP_RECNUM
            pstmt = connMyDB.prepareStatement(ENUMSQL_ZTE_PM.STAT_ZTE_CELL.SqlMyDB_ImpRecNum(""));
            pstmt.setString(1, OMC);
            pstmt.setTimestamp(2, string2Timestamp(COLLECTTIME));
            pstmt.setString(3, ENUMSQL_ZTE_PM.STAT_ZTE_CELL.getTableName());
            pstmt.setInt(4, i);
            pstmt.executeUpdate();
            connMyDB.commit();

        } catch (BatchUpdateException e) {
            // Not all of the statements were successfully executed
            int[] updateCounts = e.getUpdateCounts();
            // Some databases will continue to execute after one fails.
            // If so, updateCounts.length will equal the number of batched statements.
            // If not, updateCounts.length will equal the number of successfully executed statements
            processUpdateCounts(updateCounts);
            try {
                // Either commit the successfully executed statements or rollback the entire batch
                connOMC.rollback();
                System.out.println(OMC + "/STAT_ZTE_CELL/数据有误已经回滚");
            } catch (SQLException ex) {
                Logger.getLogger(STAT_ZTE_CELL.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (SQLException e) {
        } finally {//必须要做的清理工作
            try {
                if (rs != null) {
                    rs.close();
                    rs = null;
                }
                if (stmt != null) {
                    stmt.close();
                    stmt = null;
                }
                if (connOMC != null) {
                    connOMC.close();
                    // System.out.println(connOMC + "已经释放");
                    connOMC = null;
                }
                if (pstmt != null) {
                    pstmt.close();
                    pstmt = null;
                }
                if (connMyDB != null) {
                    connMyDB.close();
                    // System.out.println(connMyDB + "已经释放");
                    connMyDB = null;
                }

            } catch (SQLException ex) {
                Logger.getLogger(STAT_ZTE_CELL.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

    }

    /**
     *method 将字符串类型的日期转换为一个timestamp(时间戳记java.sql.Timestamp)
     *@param dateString 需要转换为timestamp的字符串
     *@return dataTime timestamp
     * 仅供 写记账薄 SELECT * FROM CSUDF_SYS_IMP_RECNUM 转换String fragment_date为 java.sql.Timestamp使用。
     */
    private java.sql.Timestamp string2Timestamp(String fragment_date) {
        java.util.Date timeDate = null;
        try {
            timeDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm").parse(fragment_date); //util类型
        } catch (ParseException ex) {
            Logger.getLogger(STAT_ZTE_CELL.class.getName()).log(Level.SEVERE, null, ex);
        }
        java.sql.Timestamp dateTime = new java.sql.Timestamp(timeDate.getTime());//Timestamp类型,timeDate.getTime()返回一个long型
        return dateTime;
    }

    public static void processUpdateCounts(int[] updateCounts) {
        for (int i = 0; i < updateCounts.length; i++) {
            if (updateCounts[i] >= 0) {
                // Successfully executed; the number represents number of affected rows
            } else if (updateCounts[i] == Statement.SUCCESS_NO_INFO) {
                // Successfully executed; number of affected rows not available
            } else if (updateCounts[i] == Statement.EXECUTE_FAILED) {
                // Failed to execute
            }
        }
    }

    //单元测试
    public static void main(String[] args) throws ParseException, InterruptedException {
        DB_ConnectManager.InitConnections();
        DB_ConnectManager.initConn_ZTE_GBSC();
        String dt = "2010-12-03 00:00";
        int v_increase = 1000 * 60 * 15;//一刻钟
        java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
        java.util.Date end = new java.util.Date(df.parse(dt).getTime());
        for (int j = 1; j < 98; j++) {
            System.out.println(df.format(end));
            String[] OMCs = new String[]{"ZTE_GBSC180", "ZTE_GBSC181", "ZTE_GBSC182", "ZTE_GBSC183", "ZTE_GBSC184", "ZTE_GBSC185", "ZTE_GBSC186"};//
            for (String OMC : OMCs) {
                Main.exeServZte.execute(new STAT_ZTE_CELL(df.format(end), OMC));
            }

            end = new java.util.Date(df.parse(dt).getTime() + v_increase * j);
        }
        Main.exeServZte.shutdown();
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics