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

    <bdo id='T2HPA'></bdo><ul id='T2HPA'></ul>

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

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

      1. OutputStream 到 DB2 數據庫表的 BLOB 列

        OutputStream to the BLOB column of a DB2 database table(OutputStream 到 DB2 數據庫表的 BLOB 列)
        1. <small id='r9CFW'></small><noframes id='r9CFW'>

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

          • <legend id='r9CFW'><style id='r9CFW'><dir id='r9CFW'><q id='r9CFW'></q></dir></style></legend>

              • <bdo id='r9CFW'></bdo><ul id='r9CFW'></ul>
                  <tbody id='r9CFW'></tbody>

                  本文介紹了OutputStream 到 DB2 數據庫表的 BLOB 列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  在 DB2 數據庫中,我有下表:

                  In a DB2 database, I have the following table:

                  CREATE TABLE MyTestTable
                  ( 
                      MYPATH VARCHAR(512) NOT NULL, 
                      MYDATA BLOB, 
                      CONSTRAINT MYTESTTABLE_PK PRIMARY KEY (MYPATH)
                  );
                  

                  使用 Java,我希望用新的 blob 數據更新此表中的現有行.我的首選方法是獲取 BLOB 列的 OutputStream &將我的數據寫入 OutputStream.

                  Using Java, I wish to update an existing row in this table with new blob data. My preferred way is to obtain an OutputStream to the BLOB column & write my data to the OutputStream.

                  這是我正在使用的測試代碼:

                  Here is the test code I am using:

                  Connection connection = null;
                  PreparedStatement pStmnt = null;
                  ResultSet rSet = null;
                  
                  try {
                      connection =  ... // get db connection
                      String id = ... // set the MYPATH value 
                  
                      String sql = "SELECT MYDATA FROM MyTestTable WHERE MYPATH='"+id+"' FOR UPDATE";
                  
                      pStmnt = connection.prepareStatement(sql);
                      rSet = pStmnt.executeQuery();
                      while (rSet.next()) {
                          Blob blobData = rSet.getBlob("MYDATA");  // this is a java.sql.Blob
                  
                          OutputStream blobOutputStream = blobData.setBinaryStream(1);
                          blobOutputStream.write(data);
                          blobOutputStream.close();
                          connection.commit();
                      }
                  }
                  // close ResultSet/PreparedStatement/etc in the finally block
                  

                  以上代碼適用于 Oracle DB.

                  The above code works for the Oracle DB.

                  但是,在 DB2 中,調用 setBinaryStream 來獲取 OutputStream 似乎不起作用.數據沒有更新,我也沒有收到任何錯誤消息.

                  However, in DB2, calling setBinaryStream to get the OutputStream does not seem to work. The data does not get updated, and I do not get any error messages.

                  問:我怎樣才能得到一個輸出流到 DB2 表的 BLOB 列?上述代碼中可能需要更改什么?

                  Qs: How can I get an OutputStream to the BLOB column of a DB2 table? What might need to be changed in the above code?

                  推薦答案

                  您可能已成功將數據寫入 Blob 對象,但您需要對 PreparedStatement 和 ResultSet 執行更多操作才能真正更新數據庫.

                  You are probably getting the data written to the Blob object successfully, but you need to do more with the PreparedStatement and ResultSet in order to actually update the value in the database.

                  首先,您的 PreparedStatement 必須使用 Connection.prepareStatement() 的版本,它采用 resultSetConcurrency 參數,您必須將其設置為值 ResultSet.CONCUR_UPDATABLE.(我不知道 SQL SELECT 實際上需要指定 FOR UPDATE 子句 - 請參閱本答案末尾鏈接中的教程.)

                  First, your PreparedStatement must be instantiated using a version of Connection.prepareStatement() that takes a resultSetConcurrency parameter, which you must set to the value ResultSet.CONCUR_UPDATABLE. (I don't know that the SQL SELECT actually needs to specify the FOR UPDATE clause - see the tutorial at the link at the end of this answer.)

                  其次,關閉 blobOutputStream 后,需要使用 updateBlob(int columnIndex, Blob x)updateBlob(StringcolumnLabel, Blob x),然后在執行 Connection.commit() 之前調用 ResultSet.updateRow().

                  Second, after you close blobOutputStream, you need to update the value in the ResultSet using updateBlob(int columnIndex, Blob x) or updateBlob(String columnLabel, Blob x), then invoke ResultSet.updateRow() before doing a Connection.commit().

                  我自己沒有以這種方式更新 Blob 值,但它應該可以工作.如果您在嘗試重用最初從 ResultSet 讀取的 Blob 時遇到任何問題(如果您實際上并未使用原始數據,則可能不需要這樣做),您可以使用 Connect.createBlob()做一個空的開始.您可以從本教程了解有關更新結果集的更多信息.

                  I haven't updated Blob values this way myself, but it should work. If you run into any issues trying to reuse the Blob originally read from the ResultSet (which you probably don't need to do if you're not actually using the original data), you can use Connect.createBlob() to make an empty one to start with. You can learn more about updating ResultSets from this tutorial.

                  這篇關于OutputStream 到 DB2 數據庫表的 BLOB 列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                    <tfoot id='ft5LI'></tfoot>

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

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

                          • <legend id='ft5LI'><style id='ft5LI'><dir id='ft5LI'><q id='ft5LI'></q></dir></style></legend>

                            主站蜘蛛池模板: 麻豆av在线免费观看 | 伊人网综合 | 草久久久 | 国产精品久久久亚洲 | 国产高清精品在线 | 91精品综合久久久久久五月天 | 亚洲精品自在在线观看 | 欧美 日韩 国产 成人 在线 | 国产精品成av人在线视午夜片 | 黑人性hd | 国产99视频精品免视看9 | 久久激情视频 | 精品中文字幕久久 | 精区3d动漫一品二品精区 | 成人h电影在线观看 | 中文字幕亚洲免费 | 日韩视频一区二区在线 | 精品欧美一区二区三区久久久 | 午夜影视 | 99免费在线观看视频 | 国产婷婷在线视频 | 日韩欧美二区 | 久久久久亚洲av毛片大全 | 久久久久久久国产 | 91精品国模一区二区三区 | 日本a∨精品中文字幕在线 亚洲91视频 | 毛色毛片免费看 | 欧美日韩国产精品一区 | 精品一区久久 | 91精品亚洲| 午夜视频在线免费观看 | 中文字幕乱码一区二区三区 | 欧美九九| 日韩av一区二区在线观看 | 欧美精品在欧美一区二区 | 色婷综合网 | 午夜精品久久久久久久久久久久 | 黄色免费网站在线看 | 一级毛片视频 | 夜夜草天天草 | 午夜精品一区二区三区在线观看 |