关注内容:将字符串类型的日期转换为一个timestamp(时间戳记java.sql.Timestamp)
package datatransfer.mot;
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_MOT_CELL extends Thread {
String dateString;
java.sql.Date JSD;//java.sql.Date是 java.util.Date 的子类
String OMC;
Connection connOMC;
Connection connMyDB;
Statement stmt;
ResultSet rs;
PreparedStatement pstmt;
int wrong_cgi = 0;
//初始化的方法必须申明为 public ,其它包才能访问
public STAT_MOT_CELL(String dateStr, String OMC) {
this.dateString = dateStr;
this.OMC = OMC;
String date = dateStr.substring(0, 10);//必须满足 yyyy-MM-dd 形式的字符串
JSD = java.sql.Date.valueOf(date);//sql类型 java.sql.Date是 java.util.Date 的子类
try {
connOMC = Main.StringMapCPDS.get(OMC).getConnection();
connMyDB = Main.WYDB.getConnection();
} catch (SQLException ex) {
Logger.getLogger(STAT_MOT_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_MOT_PM.STAT_MOT_CELL.SqlMyDB(""));
stmt = connOMC.createStatement();
rs = stmt.executeQuery(ENUMSQL_MOT_PM.STAT_MOT_CELL.SqlDataSource(dateString));
int i = 0;
String s = null, v_s = null;
java.sql.Date v_date = null;
while (rs.next()) {
i++;
try {
// //ID
// pstmt.setInt(1, 0);//CSUDF_SEQ_MOT_CELL CSUDF_TRI_MOT_CELL_S
//NE
s = rs.getString(1);
pstmt.setInt(1, Integer.parseInt(s.substring(7, 12))); //LAC INT
pstmt.setInt(2, Integer.parseInt(s.substring(13, s.length()))); //CI INT
//DATE AND TIME 从fragment_date填写绕过 rs.getDate() 出现的偶发错误
pstmt.setDate(3, JSD); //RECORD_DATE DATE
pstmt.setTimestamp(4, string2Timestamp(dateString)); //RECORD_TIME DATE
rs.getDouble(5); //BUSY_TCH_MEAN DOUBLE,仅话务量判断是否为空,每个指标都做判断影响速度
if (rs.wasNull()) {
//System.out.println(OMC + ":有空值");
pstmt.setNull(5, java.sql.Types.DOUBLE);
} else {
pstmt.setDouble(5, rs.getDouble(3));
}
//KPI,复制粘贴 《WYDB表结构.XLS》“JAVA结果集转移语句”
pstmt.setInt(6, rs.getInt(4)); //busy_tch_max INTEGER DEFAULT 0,
pstmt.setFloat(7, rs.getFloat(5)); //busy_sdcch_mean FLOAT DEFAULT 0,
pstmt.setInt(8, rs.getInt(6)); //busy_sdcch_max SMALLINT DEFAULT 0,
pstmt.setInt(9, rs.getInt(7)); //alloc_tch INTEGER DEFAULT 0,
pstmt.setInt(10, rs.getInt(8)); //alloc_tch_fail INTEGER DEFAULT 0,
pstmt.setInt(11, rs.getInt(9)); //alloc_sdcch INTEGER DEFAULT 0,
pstmt.setInt(12, rs.getInt(10)); //alloc_sdcch_fail INTEGER DEFAULT 0,
pstmt.setInt(13, rs.getInt(11)); //flow_cntrl_barred INTEGER DEFAULT 0,
pstmt.setInt(14, rs.getInt(12)); //chan_req_caus_atm INTEGER DEFAULT 0,
pstmt.setInt(15, rs.getInt(13)); //total_calls INTEGER DEFAULT 0,
pstmt.setInt(16, rs.getInt(14)); //i_intra_bs_ho_suc SMALLINT DEFAULT 0,
pstmt.setInt(17, rs.getInt(15)); //i_inter_bs_ho_suc SMALLINT DEFAULT 0,
pstmt.setInt(18, rs.getInt(16)); //assgn_redirect INTEGER DEFAULT 0,
pstmt.setInt(19, rs.getInt(17)); //rf_losses_sd INTEGER DEFAULT 0,
pstmt.setInt(20, rs.getInt(18)); //rf_loss_tch_roll INTEGER DEFAULT 0,
pstmt.setInt(21, rs.getInt(19)); //o_intra_bs_ho_los SMALLINT DEFAULT 0,
pstmt.setInt(22, rs.getInt(20)); //o_inter_bs_ho_los SMALLINT DEFAULT 0,
pstmt.setInt(23, rs.getInt(21)); //intra_cell_ho_los SMALLINT DEFAULT 0,
pstmt.setInt(24, rs.getInt(22)); //avail_tch_max INTEGER DEFAULT 0,
pstmt.setFloat(25, rs.getFloat(23)); //avail_tch_mean FLOAT DEFAULT 0,
pstmt.setInt(26, rs.getInt(24)); //avail_sdcch_max SMALLINT DEFAULT 0,
pstmt.setFloat(27, rs.getFloat(25)); //avail_sdcch_mean FLOAT DEFAULT 0,
pstmt.setFloat(28, rs.getFloat(26)); //gprs_av_pdtch_mn FLOAT DEFAULT 0,
pstmt.setFloat(29, rs.getFloat(27)); //egprs_av_pdtch_mn FLOAT DEFAULT 0,
pstmt.setInt(30, rs.getInt(28)); //cm_reestablish SMALLINT DEFAULT 0,
pstmt.setInt(31, rs.getInt(29)); //cm_serv_req_call SMALLINT DEFAULT 0,
pstmt.setInt(32, rs.getInt(30)); //cm_serv_req_sms SMALLINT DEFAULT 0,
pstmt.setInt(33, rs.getInt(31)); //cm_serv_req_emerg SMALLINT DEFAULT 0,
pstmt.setInt(34, rs.getInt(32)); //loc_flw_req_sms SMALLINT DEFAULT 0,
pstmt.setInt(35, rs.getInt(33)); //loc_flw_req_nrm SMALLINT DEFAULT 0,
pstmt.setInt(36, rs.getInt(34)); //page_response INTEGER DEFAULT 0,
pstmt.setInt(37, rs.getInt(35)); //mt_lcs_on_sdcch INTEGER DEFAULT 0,
pstmt.setInt(38, rs.getInt(36)); //sms_init_sdcch_ho INTEGER DEFAULT 0,
pstmt.setInt(39, rs.getInt(37)); //sms_init_on_sdcch SMALLINT DEFAULT 0,
pstmt.setInt(40, rs.getInt(38)); //sms_init_on_sd_req INTEGER DEFAULT 0,
pstmt.setInt(41, rs.getInt(39)); //sms_init_on_tch_fc INTEGER DEFAULT 0,
pstmt.setInt(42, rs.getInt(40)); //o_inter_bs_ho_suc SMALLINT DEFAULT 0,
pstmt.setInt(43, rs.getInt(41)); //o_intra_bs_ho_suc SMALLINT DEFAULT 0,
pstmt.setInt(44, rs.getInt(42)); //intra_cell_ho_suc SMALLINT DEFAULT 0,
pstmt.setInt(45, rs.getInt(43)); //intra_cell_ho_f_f SMALLINT DEFAULT 0,
pstmt.setInt(46, rs.getInt(44)); //intra_cell_ho_h_h SMALLINT DEFAULT 0,
pstmt.setInt(47, rs.getInt(45)); //intra_cell_ho_h_f SMALLINT DEFAULT 0,
pstmt.setInt(48, rs.getInt(46)); //intra_cell_ho_f_h SMALLINT DEFAULT 0,
pstmt.setInt(49, rs.getInt(47)); //o_inter_bs_ho_atm SMALLINT DEFAULT 0,
pstmt.setInt(50, rs.getInt(48)); //o_intra_bs_ho_atm SMALLINT DEFAULT 0,
pstmt.setInt(51, rs.getInt(49)); //call_s_post_c_tch INTEGER DEFAULT 0,
pstmt.setInt(52, rs.getInt(50)); //call_s_post_c_sd INTEGER DEFAULT 0,
pstmt.setInt(53, rs.getInt(51)); //call_s_pre_c_sd INTEGER DEFAULT 0,
pstmt.setInt(54, rs.getInt(52)); //call_s_pre_c_tch INTEGER DEFAULT 0,
pstmt.setInt(55, rs.getInt(53)); //clr_req_call_s INTEGER DEFAULT 0,
pstmt.setInt(56, rs.getInt(54)); //sms_init_on_tch SMALLINT DEFAULT 0,
pstmt.setInt(57, rs.getInt(55)); //sms_sdcch_ho_tot INTEGER DEFAULT 0,
pstmt.setInt(58, rs.getInt(56)); //num_of_sms_init INTEGER DEFAULT 0,
pstmt.setInt(59, rs.getInt(57)); //page_req_from_msc INTEGER DEFAULT 0,
pstmt.setInt(60, rs.getInt(58)); //pch_page_q_discrd INTEGER DEFAULT 0,
pstmt.setInt(61, rs.getInt(59)); //cr_page_response INTEGER DEFAULT 0,
pstmt.setInt(62, rs.getInt(60)); //pacch_page_reqs INTEGER DEFAULT 0,
pstmt.setInt(63, rs.getInt(61)); //ok_acc_proc INTEGER DEFAULT 0,
pstmt.setInt(64, rs.getInt(62)); //tch_congestion INTEGER DEFAULT 0,
pstmt.setInt(65, rs.getInt(63)); //sdcch_congestion INTEGER DEFAULT 0,
pstmt.setFloat(66, rs.getFloat(64)); //tch_delay_mean FLOAT DEFAULT 0,
pstmt.setInt(67, rs.getInt(65)); //tch_delay_max INTEGER DEFAULT 0,
pstmt.setFloat(68, rs.getFloat(66)); //ul_busy_pdtch_mean FLOAT DEFAULT 0,
pstmt.setInt(69, rs.getInt(67)); //ul_busy_pdtch_max INTEGER DEFAULT 0,
pstmt.setFloat(70, rs.getFloat(68)); //dl_busy_pdtch_mean FLOAT DEFAULT 0,
pstmt.setInt(71, rs.getInt(69)); //dl_busy_pdtch_max INTEGER DEFAULT 0,
pstmt.setInt(72, rs.getInt(70)); //intra_cell_ho_atm SMALLINT DEFAULT 0,
pstmt.setInt(73, rs.getInt(71)); //intra_cell_ho_ret SMALLINT DEFAULT 0,
pstmt.setInt(74, rs.getInt(72)); //intra_cell_ho_req SMALLINT DEFAULT 0,
pstmt.setInt(75, rs.getInt(73)); //intra_cell_eqp_fa SMALLINT DEFAULT 0,
pstmt.setInt(76, rs.getInt(74)); //intra_cell SMALLINT DEFAULT 0,
pstmt.setInt(77, rs.getInt(75)); //intra_cell_ho_clr SMALLINT DEFAULT 0,
pstmt.setInt(78, rs.getInt(76)); //intra_cell_dynet SMALLINT DEFAULT 0,
pstmt.setInt(79, rs.getInt(77)); //intra_cell_ho_s_s SMALLINT DEFAULT 0,
pstmt.setInt(80, rs.getInt(78)); //i_inter_bs_eq_fa SMALLINT DEFAULT 0,
pstmt.setInt(81, rs.getInt(79)); //i_inter_bs_ho_clr SMALLINT DEFAULT 0,
pstmt.setInt(82, rs.getInt(80)); //i_intra_bs_ho_los SMALLINT DEFAULT 0,
pstmt.setInt(83, rs.getInt(81)); //i_intra_bs_eq_fa SMALLINT DEFAULT 0,
pstmt.setInt(84, rs.getInt(82)); //i_intra_bs_ho_ret SMALLINT DEFAULT 0,
pstmt.setInt(85, rs.getInt(83)); //i_inter_bs_ms_ns SMALLINT DEFAULT 0,
pstmt.setInt(86, rs.getInt(84)); //i_intra_bs_ho_clr SMALLINT DEFAULT 0,
pstmt.setInt(87, rs.getInt(85)); //sdch_i_intra_b_h_s INTEGER DEFAULT 0,
pstmt.setInt(88, rs.getInt(86)); //ohoa_upqual SMALLINT DEFAULT 0,
pstmt.setInt(89, rs.getInt(87)); //ohoa_uplevel SMALLINT DEFAULT 0,
pstmt.setInt(90, rs.getInt(88)); //ohoa_downqual SMALLINT DEFAULT 0,
pstmt.setInt(91, rs.getInt(89)); //ohoa_downlevel SMALLINT DEFAULT 0,
pstmt.setInt(92, rs.getInt(90)); //ohoa_distance SMALLINT DEFAULT 0,
pstmt.setInt(93, rs.getInt(91)); //ohoa_upinterf SMALLINT DEFAULT 0,
pstmt.setInt(94, rs.getInt(92)); //ohoa_downinterf SMALLINT DEFAULT 0,
pstmt.setInt(95, rs.getInt(93)); //ohoa_powerbdgt INTEGER DEFAULT 0,
pstmt.setInt(96, rs.getInt(94)); //ohoa_congestion SMALLINT DEFAULT 0,
pstmt.setInt(97, rs.getInt(95)); //ohoa_adj_chn_intf SMALLINT DEFAULT 0,
pstmt.setInt(98, rs.getInt(96)); //ohoa_band_reasign SMALLINT DEFAULT 0,
pstmt.setInt(99, rs.getInt(97)); //ohoa_bandhandover SMALLINT DEFAULT 0,
pstmt.setInt(100, rs.getInt(98)); //dl_rlc_nack_blks INTEGER DEFAULT 0,
pstmt.setInt(101, rs.getInt(99)); //dl_rlc_nak_new_bks INTEGER DEFAULT 0,
pstmt.setInt(102, rs.getInt(100)); //dl_rlc_ack_new_bks INTEGER DEFAULT 0,
pstmt.setInt(103, rs.getInt(101)); //dl_rlc_retx_blks INTEGER DEFAULT 0,
pstmt.setInt(104, rs.getInt(102)); //ul_rlc_nack_blks INTEGER DEFAULT 0,
pstmt.setInt(105, rs.getInt(103)); //ul_rlc_una_new_bks INTEGER DEFAULT 0,
pstmt.setInt(106, rs.getInt(104)); //ul_rlc_ack_new_bks INTEGER DEFAULT 0,
pstmt.setInt(107, rs.getInt(105)); //ul_rlc_retx_blks INTEGER DEFAULT 0,
pstmt.setInt(108, rs.getInt(106)); //dlrlcnackblks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(109, rs.getInt(107)); //dlrlcnackblks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(110, rs.getInt(108)); //dlrlcnackblks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(111, rs.getInt(109)); //dlrlcnackblks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(112, rs.getInt(110)); //dlrlcnackblks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(113, rs.getInt(111)); //dlrlcnackblks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(114, rs.getInt(112)); //dlrlcnackblks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(115, rs.getInt(113)); //dlrlcnackblks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(116, rs.getInt(114)); //dlrlcnackblks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(117, rs.getInt(115)); //dlrlcnackblks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(118, rs.getInt(116)); //dlrlcnackblks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(119, rs.getInt(117)); //dlrlcnackblks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(120, rs.getInt(118)); //dlrlcnackblks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(121, rs.getInt(119)); //dlrlcnanewbks_cs1 INTEGER DEFAULT 0,
pstmt.setInt(122, rs.getInt(120)); //dlrlcnanewbks_cs2 INTEGER DEFAULT 0,
pstmt.setInt(123, rs.getInt(121)); //dlrlcnanewbks_cs3 INTEGER DEFAULT 0,
pstmt.setInt(124, rs.getInt(122)); //dlrlcnanewbks_cs4 INTEGER DEFAULT 0,
pstmt.setInt(125, rs.getInt(123)); //dlrlcnanewbks_mcs1 INTEGER DEFAULT 0,
pstmt.setInt(126, rs.getInt(124)); //dlrlcnanewbks_mcs2 INTEGER DEFAULT 0,
pstmt.setInt(127, rs.getInt(125)); //dlrlcnanewbks_mcs3 INTEGER DEFAULT 0,
pstmt.setInt(128, rs.getInt(126)); //dlrlcnanewbks_mcs4 INTEGER DEFAULT 0,
pstmt.setInt(129, rs.getInt(127)); //dlrlcnanewbks_mcs5 INTEGER DEFAULT 0,
pstmt.setInt(130, rs.getInt(128)); //dlrlcnanewbks_mcs6 INTEGER DEFAULT 0,
pstmt.setInt(131, rs.getInt(129)); //dlrlcnanewbks_mcs7 INTEGER DEFAULT 0,
pstmt.setInt(132, rs.getInt(130)); //dlrlcnanewbks_mcs8 INTEGER DEFAULT 0,
pstmt.setInt(133, rs.getInt(131)); //dlrlcnanewbks_mcs9 INTEGER DEFAULT 0,
pstmt.setInt(134, rs.getInt(132)); //dlrlcaknewbks_cs1 INTEGER DEFAULT 0,
pstmt.setInt(135, rs.getInt(133)); //dlrlcaknewbks_cs2 INTEGER DEFAULT 0,
pstmt.setInt(136, rs.getInt(134)); //dlrlcaknewbks_cs3 INTEGER DEFAULT 0,
pstmt.setInt(137, rs.getInt(135)); //dlrlcaknewbks_cs4 INTEGER DEFAULT 0,
pstmt.setInt(138, rs.getInt(136)); //dlrlcaknewbks_mcs1 INTEGER DEFAULT 0,
pstmt.setInt(139, rs.getInt(137)); //dlrlcaknewbks_mcs2 INTEGER DEFAULT 0,
pstmt.setInt(140, rs.getInt(138)); //dlrlcaknewbks_mcs3 INTEGER DEFAULT 0,
pstmt.setInt(141, rs.getInt(139)); //dlrlcaknewbks_mcs4 INTEGER DEFAULT 0,
pstmt.setInt(142, rs.getInt(140)); //dlrlcaknewbks_mcs5 INTEGER DEFAULT 0,
pstmt.setInt(143, rs.getInt(141)); //dlrlcaknewbks_mcs6 INTEGER DEFAULT 0,
pstmt.setInt(144, rs.getInt(142)); //dlrlcaknewbks_mcs7 INTEGER DEFAULT 0,
pstmt.setInt(145, rs.getInt(143)); //dlrlcaknewbks_mcs8 INTEGER DEFAULT 0,
pstmt.setInt(146, rs.getInt(144)); //dlrlcaknewbks_mcs9 INTEGER DEFAULT 0,
pstmt.setInt(147, rs.getInt(145)); //dlrlcretxblks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(148, rs.getInt(146)); //dlrlcretxblks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(149, rs.getInt(147)); //dlrlcretxblks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(150, rs.getInt(148)); //dlrlcretxblks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(151, rs.getInt(149)); //dlrlcretxblks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(152, rs.getInt(150)); //dlrlcretxblks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(153, rs.getInt(151)); //dlrlcretxblks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(154, rs.getInt(152)); //dlrlcretxblks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(155, rs.getInt(153)); //dlrlcretxblks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(156, rs.getInt(154)); //dlrlcretxblks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(157, rs.getInt(155)); //dlrlcretxblks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(158, rs.getInt(156)); //dlrlcretxblks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(159, rs.getInt(157)); //dlrlcretxblks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(160, rs.getInt(158)); //ulrlcnackblks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(161, rs.getInt(159)); //ulrlcnackblks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(162, rs.getInt(160)); //ulrlcnackblks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(163, rs.getInt(161)); //ulrlcnackblks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(164, rs.getInt(162)); //ulrlcnackblks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(165, rs.getInt(163)); //ulrlcnackblks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(166, rs.getInt(164)); //ulrlcnackblks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(167, rs.getInt(165)); //ulrlcnackblks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(168, rs.getInt(166)); //ulrlcnackblks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(169, rs.getInt(167)); //ulrlcnackblks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(170, rs.getInt(168)); //ulrlcnackblks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(171, rs.getInt(169)); //ulrlcnackblks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(172, rs.getInt(170)); //ulrlcnackblks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(173, rs.getInt(171)); //ulrlcnanewbks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(174, rs.getInt(172)); //ulrlcnanewbks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(175, rs.getInt(173)); //ulrlcnanewbks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(176, rs.getInt(174)); //ulrlcnanewbks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(177, rs.getInt(175)); //ulrlcnanewbks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(178, rs.getInt(176)); //ulrlcnanewbks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(179, rs.getInt(177)); //ulrlcnanewbks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(180, rs.getInt(178)); //ulrlcnanewbks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(181, rs.getInt(179)); //ulrlcnanewbks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(182, rs.getInt(180)); //ulrlcnanewbks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(183, rs.getInt(181)); //ulrlcnanewbks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(184, rs.getInt(182)); //ulrlcnanewbks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(185, rs.getInt(183)); //ulrlcnanewbks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(186, rs.getInt(184)); //ulrlcaknewbks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(187, rs.getInt(185)); //ulrlcaknewbks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(188, rs.getInt(186)); //ulrlcaknewbks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(189, rs.getInt(187)); //ulrlcaknewbks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(190, rs.getInt(188)); //ulrlcaknewbks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(191, rs.getInt(189)); //ulrlcaknewbks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(192, rs.getInt(190)); //ulrlcaknewbks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(193, rs.getInt(191)); //ulrlcaknewbks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(194, rs.getInt(192)); //ulrlcaknewbks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(195, rs.getInt(193)); //ulrlcaknewbks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(196, rs.getInt(194)); //ulrlcaknewbks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(197, rs.getInt(195)); //ulrlcaknewbks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(198, rs.getInt(196)); //ulrlcaknewbks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(199, rs.getInt(197)); //ulrlc_retxbks_cs1 SMALLINT DEFAULT 0,
pstmt.setInt(200, rs.getInt(198)); //ulrlc_retxbks_cs2 SMALLINT DEFAULT 0,
pstmt.setInt(201, rs.getInt(199)); //ulrlc_retxbks_cs3 SMALLINT DEFAULT 0,
pstmt.setInt(202, rs.getInt(200)); //ulrlc_retxbks_cs4 SMALLINT DEFAULT 0,
pstmt.setInt(203, rs.getInt(201)); //ulrlc_retxbks_mcs1 SMALLINT DEFAULT 0,
pstmt.setInt(204, rs.getInt(202)); //ulrlc_retxbks_mcs2 SMALLINT DEFAULT 0,
pstmt.setInt(205, rs.getInt(203)); //ulrlc_retxbks_mcs3 SMALLINT DEFAULT 0,
pstmt.setInt(206, rs.getInt(204)); //ulrlc_retxbks_mcs4 SMALLINT DEFAULT 0,
pstmt.setInt(207, rs.getInt(205)); //ulrlc_retxbks_mcs5 SMALLINT DEFAULT 0,
pstmt.setInt(208, rs.getInt(206)); //ulrlc_retxbks_mcs6 SMALLINT DEFAULT 0,
pstmt.setInt(209, rs.getInt(207)); //ulrlc_retxbks_mcs7 SMALLINT DEFAULT 0,
pstmt.setInt(210, rs.getInt(208)); //ulrlc_retxbks_mcs8 SMALLINT DEFAULT 0,
pstmt.setInt(211, rs.getInt(209)); //ulrlc_retxbks_mcs9 SMALLINT DEFAULT 0,
pstmt.setInt(212, rs.getInt(210)); //gprs_cell_congest SMALLINT DEFAULT 0,
pstmt.setInt(213, rs.getInt(211)); //gprs_cellcong_25 SMALLINT DEFAULT 0,
pstmt.setInt(214, rs.getInt(212)); //gprs_cellcong_30 SMALLINT DEFAULT 0,
pstmt.setInt(215, rs.getInt(213)); //gprs_cellcong_35 SMALLINT DEFAULT 0,
pstmt.setInt(216, rs.getInt(214)); //gprs_cellcong_40 SMALLINT DEFAULT 0,
pstmt.setInt(217, rs.getInt(215)); //gprs_cellcong_45 SMALLINT DEFAULT 0,
pstmt.setInt(218, rs.getInt(216)); //gprs_cellcong_50 SMALLINT DEFAULT 0,
pstmt.setInt(219, rs.getInt(217)); //gprs_cellcong_55 SMALLINT DEFAULT 0,
pstmt.setInt(220, rs.getInt(218)); //gprs_cellcong_60 SMALLINT DEFAULT 0,
pstmt.setInt(221, rs.getInt(219)); //gprs_cellcong_65 SMALLINT DEFAULT 0,
pstmt.setInt(222, rs.getInt(220)); //gprs_cellcong_70 SMALLINT DEFAULT 0,
pstmt.setInt(223, rs.getInt(221)); //gprs_cellcong_75 SMALLINT DEFAULT 0,
pstmt.setInt(224, rs.getInt(222)); //gprs_cellcong_80 SMALLINT DEFAULT 0,
pstmt.setInt(225, rs.getInt(223)); //gprs_cellcong_85 SMALLINT DEFAULT 0,
pstmt.setInt(226, rs.getInt(224)); //gprs_cellcong_90 SMALLINT DEFAULT 0,
pstmt.setInt(227, rs.getInt(225)); //gprs_cellcong_95 SMALLINT DEFAULT 0,
pstmt.setInt(228, rs.getInt(226)); //gprs_cellcong_100 SMALLINT DEFAULT 0,
pstmt.setInt(229, rs.getInt(227)); //ch_reqs_succ INTEGER DEFAULT 0,
pstmt.setInt(230, rs.getInt(228)); //ch_reqs_succ_p_c INTEGER DEFAULT 0,
pstmt.setInt(231, rs.getInt(229)); //ch_reqs_succ_p_p INTEGER DEFAULT 0,
pstmt.setInt(232, rs.getInt(230)); //ch_reqs_succ_b_c INTEGER DEFAULT 0,
pstmt.setInt(233, rs.getInt(231)); //ch_reqs_succ_b_p INTEGER DEFAULT 0,
pstmt.setInt(234, rs.getInt(232)); //ch_reqs_succ_p_r INTEGER DEFAULT 0,
pstmt.setInt(235, rs.getInt(233)); //ch_reqs_succ_cp_a INTEGER DEFAULT 0,
pstmt.setInt(236, rs.getInt(234)); //ch_reqs_succ_e_c INTEGER DEFAULT 0,
pstmt.setInt(237, rs.getInt(235)); //ch_reqs_succ_pkts INTEGER DEFAULT 0,
pstmt.setInt(238, rs.getInt(236)); //chanreqsucce1ccc INTEGER DEFAULT 0,
pstmt.setInt(239, rs.getInt(237)); //chanreqsucce1pccc INTEGER DEFAULT 0,
pstmt.setInt(240, rs.getInt(238)); //chanreqsuccesbccc INTEGER DEFAULT 0,
pstmt.setInt(241, rs.getInt(239)); //chanreqsuccesbpccc INTEGER DEFAULT 0,
pstmt.setInt(242, rs.getInt(240)); //chanreqsuccepuaprr INTEGER DEFAULT 0,
pstmt.setInt(243, rs.getInt(241)); //chanreqsucceptr INTEGER DEFAULT 0,
pstmt.setInt(244, rs.getInt(242)); //chanreqsuccepuapda INTEGER DEFAULT 0,
pstmt.setInt(245, rs.getInt(243)); //chan_reqs_rec_p_c INTEGER DEFAULT 0,
pstmt.setInt(246, rs.getInt(244)); //chan_reqs_rec_p_p INTEGER DEFAULT 0,
pstmt.setInt(247, rs.getInt(245)); //chan_reqs_rec_b_c INTEGER DEFAULT 0,
pstmt.setInt(248, rs.getInt(246)); //chan_reqs_rec_b_p INTEGER DEFAULT 0,
pstmt.setInt(249, rs.getInt(247)); //chan_reqs_rec_p_r INTEGER DEFAULT 0,
pstmt.setInt(250, rs.getInt(248)); //chan_reqs_rec_cp_a INTEGER DEFAULT 0,
pstmt.setInt(251, rs.getInt(249)); //chan_reqs_rec_e_c INTEGER DEFAULT 0,
pstmt.setInt(252, rs.getInt(250)); //chnlrqrecegprs1pc INTEGER DEFAULT 0,
pstmt.setInt(253, rs.getInt(251)); //chnlrqrecegprs1ppc INTEGER DEFAULT 0,
pstmt.setInt(254, rs.getInt(252)); //chnlrqrecegprssbc INTEGER DEFAULT 0,
pstmt.setInt(255, rs.getInt(253)); //chnlrqrecegprssbpc INTEGER DEFAULT 0,
pstmt.setInt(256, rs.getInt(254)); //chnlrqrecegprspkrq INTEGER DEFAULT 0,
pstmt.setInt(257, rs.getInt(255)); //chnlrqrecegprscrpd INTEGER DEFAULT 0,
pstmt.setInt(258, rs.getInt(256)); //channel_reqs_rec INTEGER DEFAULT 0,
pstmt.setInt(259, rs.getInt(257)); //channel_reqs_rej INTEGER DEFAULT 0,
pstmt.setInt(260, rs.getInt(258)); //gbl_flow_ctrl_sent INTEGER DEFAULT 0,
pstmt.setInt(261, rs.getInt(259)); //air_ul_data_blks INTEGER DEFAULT 0,
pstmt.setInt(262, rs.getInt(260)); //air_dl_data_blks INTEGER DEFAULT 0,
pstmt.setInt(263, rs.getInt(261)); //gprs_ch_switched INTEGER DEFAULT 0,
pstmt.setInt(264, rs.getInt(262)); //gprs_ch_swtch_cs SMALLINT DEFAULT 0,
pstmt.setInt(265, rs.getInt(263)); //gprs_ch_swtch_vgcs SMALLINT DEFAULT 0,
pstmt.setInt(266, rs.getInt(264)); //gprs_acc_per_agch INTEGER DEFAULT 0,
pstmt.setInt(267, rs.getInt(265)); //gprs_acc_per_rach INTEGER DEFAULT 0,
//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_MOT_PM.STAT_MOT_CELL.getTableName() + "数据导入完成" + i + "条记录。");
long endTime = System.currentTimeMillis();
System.out.println("采集耗时:" + (endTime - startTime) / 1000 + "秒");
//写记账薄 SELECT * FROM CSUDF_SYS_IMP_RECNUM
pstmt = connMyDB.prepareStatement(ENUMSQL_MOT_PM.STAT_MOT_CELL.SqlMyDB_ImpRecNum(""));
pstmt.setString(1, OMC);
pstmt.setTimestamp(2, string2Timestamp(dateString));
pstmt.setString(3, ENUMSQL_MOT_PM.STAT_MOT_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_MOT_CELL/数据有误已经回滚");
} catch (SQLException ex) {
Logger.getLogger(STAT_MOT_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_MOT_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_MOT_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();
String dt = "2010-12-01 07:00";
String[] OMCs = new String[]{"OMCSP1", "OMCSP9", "OMCSP11"};//, "OMCSP9", "OMCSP11"
for (String OMC : OMCs) {
Main.exeServMot.execute(new STAT_MOT_CELL(dt, OMC));
}
Main.exeServMot.shutdown();
}
}