pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    1. <small id='fptWi'></small><noframes id='fptWi'>

    2. <i id='fptWi'><tr id='fptWi'><dt id='fptWi'><q id='fptWi'><span id='fptWi'><b id='fptWi'><form id='fptWi'><ins id='fptWi'></ins><ul id='fptWi'></ul><sub id='fptWi'></sub></form><legend id='fptWi'></legend><bdo id='fptWi'><pre id='fptWi'><center id='fptWi'></center></pre></bdo></b><th id='fptWi'></th></span></q></dt></tr></i><div class="xnfnjjt" id='fptWi'><tfoot id='fptWi'></tfoot><dl id='fptWi'><fieldset id='fptWi'></fieldset></dl></div>
      <legend id='fptWi'><style id='fptWi'><dir id='fptWi'><q id='fptWi'></q></dir></style></legend>

      <tfoot id='fptWi'></tfoot>

        <bdo id='fptWi'></bdo><ul id='fptWi'></ul>
      1. 加載.csv文件時(shí)如何將當(dāng)前系統(tǒng)時(shí)間戳插入db2數(shù)據(jù)

        How to insert the current system timestamp into db2 database base column when .csv file is loaded(加載.csv文件時(shí)如何將當(dāng)前系統(tǒng)時(shí)間戳插入db2數(shù)據(jù)庫基列)

        • <i id='yzhSy'><tr id='yzhSy'><dt id='yzhSy'><q id='yzhSy'><span id='yzhSy'><b id='yzhSy'><form id='yzhSy'><ins id='yzhSy'></ins><ul id='yzhSy'></ul><sub id='yzhSy'></sub></form><legend id='yzhSy'></legend><bdo id='yzhSy'><pre id='yzhSy'><center id='yzhSy'></center></pre></bdo></b><th id='yzhSy'></th></span></q></dt></tr></i><div class="1v1hjhx" id='yzhSy'><tfoot id='yzhSy'></tfoot><dl id='yzhSy'><fieldset id='yzhSy'></fieldset></dl></div>
          <tfoot id='yzhSy'></tfoot>
            <bdo id='yzhSy'></bdo><ul id='yzhSy'></ul>

            <small id='yzhSy'></small><noframes id='yzhSy'>

              <tbody id='yzhSy'></tbody>

            <legend id='yzhSy'><style id='yzhSy'><dir id='yzhSy'><q id='yzhSy'></q></dir></style></legend>

                1. 本文介紹了加載.csv文件時(shí)如何將當(dāng)前系統(tǒng)時(shí)間戳插入db2數(shù)據(jù)庫基列的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  下面的類會(huì)將 .csv 導(dǎo)入數(shù)據(jù)庫表.它工作正常,現(xiàn)在我需要更新同一個(gè)表中需要獲取當(dāng)前系統(tǒng)時(shí)間戳的另一列當(dāng)該程序在數(shù)據(jù)庫表的相應(yīng)列中執(zhí)行時(shí)得到更新.

                  The below class will import the .csv into database table.it is working fine and Now i need to update another column in same table where current system timestamp needs to get get updated when this program is executed in the respective column of the database table.

                  示例:在 Db2 表中,主題列是:英語社會(huì)數(shù)學(xué)時(shí)間戳

                  Example: In Db2 table Subjects columns are: Eng Social Maths TimeStamp

                  在 .CSV 文件中只有 3 列 Eng Social Maths .

                  In .CSV file has only 3 columns Eng Social Maths .

                  當(dāng) .csv 文件被導(dǎo)入(使用上述程序)到 db2 時(shí),所有列都會(huì)更新,除了 TimeStamp.時(shí)間戳用于記錄 .csv 文件何時(shí)上傳到表格.那么,如何同時(shí)使用當(dāng)前系統(tǒng)時(shí)間戳更新 TimeStamp 列.?請(qǐng)幫忙

                  When .csv file is imported (using above program) to db2 all the columns are updated except TimeStamp. Timestamp is inculded to tack the when .csv file is uploaded to table. So, how to Update the TimeStamp column with Current System timestamp simultaneously .? Please help

                  公共類 CSVLoader {

                  public class CSVLoader {

                  private static final 
                      String SQL_INSERT = "INSERT INTO OPPTYMGMT.${table}
                           (${keys})      VALUES(${values})";
                  
                  private static final String TABLE_REGEX = "\$\{table\}";
                  
                  private static final String KEYS_REGEX = "\$\{keys\}";
                  
                  private static final String VALUES_REGEX = "\$\{values\}";
                  
                  private Connection connection;
                  
                  private char seprator;
                  
                  public CSVLoader(Connection connection) {
                  
                      this.connection = connection;
                  
                      //Set default separator
                  
                      this.seprator = ',';
                  }
                  
                        public void loadCSV(String csvFile, String tableName) throws Exception {
                  
                      CSVReader csvReader = null;
                  
                      if(null == this.connection) {
                  
                          throw new Exception("Not a valid connection.");
                      }
                  
                      try {
                  
                          csvReader = new CSVReader(new FileReader(csvFile), this.seprator);
                  
                      } catch (Exception e) {
                  
                          e.printStackTrace();
                  
                          throw new Exception("Error occured while executing file. "
                  
                                     + e.getMessage());
                  
                                }
                  
                          String[] headerRow = csvReader.readNext();
                  
                      if (null == headerRow) {
                  
                          throw new FileNotFoundException(
                  
                  
                                          "No columns defined in given CSV file." +
                  
                                           "Please check the CSV file format.");
                      }
                  
                      String questionmarks = StringUtils.repeat("?,", headerRow.length);
                  
                      questionmarks = (String) questionmarks.subSequence(0, questionmarks
                  
                              .length() - 1);
                  
                  
                      String query = SQL_INSERT.replaceFirst(TABLE_REGEX, tableName);
                  
                      query = query
                              .replaceFirst(KEYS_REGEX, StringUtils.join
                  
                               (headerRow,   ","));
                  
                      query = query.replaceFirst(VALUES_REGEX, questionmarks);
                  
                              System.out.println("Query: " + query);
                  
                      String[] nextLine;
                  
                      Connection con = null;
                  
                      PreparedStatement ps = null;
                  
                      try {
                          con = this.connection;
                  
                          con.setAutoCommit(false);
                  
                          ps = con.prepareStatement(query);
                  
                                         final int batchSize = 1000;
                  
                                       int count = 0;
                  
                          Date date = null;
                  
                          while ((nextLine = csvReader.readNext()) != null) {
                  
                              System.out.println( "inside while" );
                  
                              if (null != nextLine) {
                  
                                  int index = 1;
                  
                                  for (String string : nextLine) {
                  
                                      date = DateUtil.convertToDate(string);
                  
                          if (null != date) {
                  
                                      ps.setDate(index++, new java.sql.Date(date
                  
                                      .getTime()));
                  
                                       } else {
                  
                                    ps.setString(index++, string);
                  
                      System.out.println( "string" +string);
                  
                                      }
                  
                                  }
                  
                                  ps.addBatch();
                  
                              }
                  
                              if (++count % batchSize == 0) {
                  
                                  ps.executeBatch();
                  
                              }
                  
                                       }
                  
                  
                          ps.executeBatch(); // insert remaining records
                  
                          con.commit();
                  
                      } catch (Exception e) {
                  
                          con.rollback();
                  
                          e.printStackTrace();
                  
                          throw new Exception(
                  
                          "Error occured while loading data 
                  
                                  from file                to                      database."
                  
                                 + e.getMessage());
                  
                      } finally {
                  
                               if (null != ps)
                  
                  
                              ps.close();
                  
                          if (null != con)
                  
                              con.close();
                  
                              System.out.println("csvReader will be closed");
                  
                          csvReader.close();
                  
                      }
                  
                  }
                  
                  public char getSeprator() {
                  
                      return seprator;
                  
                  }
                  
                  public void setSeprator(char seprator) {
                  
                      this.seprator = seprator;
                  
                  }
                  
                  
                           }
                  

                  推薦答案

                  private static final 
                   String SQL_INSERT = "INSERT INTO OPPTYMGMT.${table}
                       (${keys}, my_timestamp_column)      VALUES(${values}, current_timestamp)";
                  

                  這篇關(guān)于加載.csv文件時(shí)如何將當(dāng)前系統(tǒng)時(shí)間戳插入db2數(shù)據(jù)庫基列的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)
                  • <bdo id='OZFmK'></bdo><ul id='OZFmK'></ul>

                        <small id='OZFmK'></small><noframes id='OZFmK'>

                            <tbody id='OZFmK'></tbody>
                        1. <i id='OZFmK'><tr id='OZFmK'><dt id='OZFmK'><q id='OZFmK'><span id='OZFmK'><b id='OZFmK'><form id='OZFmK'><ins id='OZFmK'></ins><ul id='OZFmK'></ul><sub id='OZFmK'></sub></form><legend id='OZFmK'></legend><bdo id='OZFmK'><pre id='OZFmK'><center id='OZFmK'></center></pre></bdo></b><th id='OZFmK'></th></span></q></dt></tr></i><div class="xdjv71h" id='OZFmK'><tfoot id='OZFmK'></tfoot><dl id='OZFmK'><fieldset id='OZFmK'></fieldset></dl></div>
                            <legend id='OZFmK'><style id='OZFmK'><dir id='OZFmK'><q id='OZFmK'></q></dir></style></legend>

                            <tfoot id='OZFmK'></tfoot>
                            主站蜘蛛池模板: pos机办理,智能/扫码/二维码/微信支付宝pos机-北京万汇通宝商贸有限公司 | 包装设计公司,产品包装设计|包装制作,包装盒定制厂家-汇包装【官方网站】 | 真空粉体取样阀,电动楔式闸阀,电动针型阀-耐苛尔(上海)自动化仪表有限公司 | 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 安徽集装箱厂-合肥国彩钢结构板房工程有限公司| 上海公众号开发-公众号代运营公司-做公众号的公司企业服务商-咏熠软件 | 整车VOC采样环境舱-甲醛VOC预处理舱-多舱法VOC检测环境仓-上海科绿特科技仪器有限公司 | 世纪豪门官网 世纪豪门集成吊顶加盟电话 世纪豪门售后电话 | 浙江筋膜枪-按摩仪厂家-制造商-肩颈按摩仪哪家好-温州市合喜电子科技有限公司 | 蔬菜配送公司|蔬菜配送中心|食材配送|饭堂配送|食堂配送-首宏公司 | 照相馆预约系统,微信公众号摄影门店系统,影楼管理软件-盟百网络 | 长沙中央空调维修,中央空调清洗维保,空气能热水工程,价格,公司就找维小保-湖南维小保环保科技有限公司 | CE认证_产品欧盟ROHS-REACH检测机构-商通检测 | 流程管理|流程管理软件|企业流程管理|微宏科技-AlphaFlow_流程管理系统软件服务商 | 植筋胶-粘钢胶-碳纤维布-碳纤维板-环氧砂浆-加固材料生产厂家-上海巧力建筑科技有限公司 | 发电机价格|发电机组价格|柴油发电机价格|柴油发电机组价格网 | YAGEO国巨电容|贴片电阻|电容价格|三星代理商-深圳市巨优电子有限公司 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 精密光学实验平台-红外粉末压片机模具-天津博君 | 重庆钣金加工厂家首页-专业定做监控电视墙_操作台 | 氧化铁红厂家-淄博宗昂化工| 上海小程序开发-小程序制作-上海小程序定制开发公司-微信商城小程序-上海咏熠 | 青岛侦探_青岛侦探事务所_青岛劝退小三_青岛调查出轨取证公司_青岛婚外情取证-青岛探真调查事务所 | 祝融环境-地源热泵多恒系统高新技术企业,舒适生活环境缔造者! | AGV无人叉车_激光叉车AGV_仓储AGV小车_AGV无人搬运车-南昌IKV机器人有限公司[官网] | 物流之家新闻网-最新物流新闻|物流资讯|物流政策|物流网-匡匡奈斯物流科技 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 婚博会2024时间表_婚博会门票领取_婚博会地址-婚博会官网 | 桥架-槽式电缆桥架-镀锌桥架-托盘式桥架 - 上海亮族电缆桥架制造有限公司 | 闭端端子|弹簧螺式接线头|防水接线头|插线式接线头|端子台|电源线扣+护线套|印刷电路板型端子台|金笔电子代理商-上海拓胜电气有限公司 | 艾乐贝拉细胞研究中心 | 国家组织工程种子细胞库华南分库 | 流变仪-热分析联用仪-热膨胀仪厂家-耐驰科学仪器商贸 | 进口便携式天平,外校_十万分之一分析天平,奥豪斯工业台秤,V2000防水秤-重庆珂偌德科技有限公司(www.crdkj.com) | 济南网站策划设计_自适应网站制作_H5企业网站搭建_济南外贸网站制作公司_锐尚 | 四川职高信息网-初高中、大专、职业技术学校招生信息网 | 开平机_纵剪机厂家_开平机生产厂家|诚信互赢-泰安瑞烨精工机械制造有限公司 | 数码管_LED贴片灯_LED数码管厂家-无锡市冠卓电子科技有限公司 | 光谱仪_积分球_分布光度计_灯具检测生产厂家_杭州松朗光电【官网】 | 机床主轴维修|刀塔维修|C轴维修-常州翔高精密机械有限公司 | 直线模组_滚珠丝杆滑台_模组滑台厂家_万里疆科技 | 超声波焊接机,振动摩擦焊接机,激光塑料焊接机,超声波焊接模具工装-德召尼克(常州)焊接科技有限公司 |