久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    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="qwawimqqmiuu" 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ù)庫(kù)基列)

        • <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="qwawimqqmiuu" 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ù)庫(kù)基列的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  下面的類會(huì)將 .csv 導(dǎo)入數(shù)據(jù)庫(kù)表.它工作正常,現(xiàn)在我需要更新同一個(gè)表中需要獲取當(dāng)前系統(tǒng)時(shí)間戳的另一列當(dāng)該程序在數(shù)據(jù)庫(kù)表的相應(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ù)庫(kù)基列的文章就介紹到這了,希望我們推薦的答案對(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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 97精品超碰一区二区三区 | 国产精品久久久久一区二区三区 | 久久免费小视频 | 精品久久一区 | 国产91久久精品一区二区 | 久久1区| 天天影视亚洲综合网 | 三级在线免费观看 | 精品久草| 一区二区三区免费 | 国产精品福利视频 | 亚洲欧美日韩国产综合 | 九九99精品 | 国产美女一区二区 | 黄色毛片在线观看 | 日韩激情在线 | 中文字幕亚洲欧美 | 国产成人一区二区 | 欧美理论| 久久久久九九九女人毛片 | 欧美日韩精品一区二区三区四区 | 国产精品激情小视频 | 日本aaa视频 | 国产精品久久久久久久久久 | 欧美激情久久久 | k8久久久一区二区三区 | 日韩欧美国产一区二区三区 | 日本成人三级电影 | 国产精品福利在线观看 | 一级黄片一级毛片 | 欧美精品久久久 | 色婷婷激情综合 | 九色91视频| 国偷自产av一区二区三区 | 91久久久久 | 欧美一级三级在线观看 | 国产精品久久久久久吹潮 | 人人做人人澡人人爽欧美 | 欧美日韩精品久久久免费观看 | av网站免费看 | 狠狠爱一区二区三区 |