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

    <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="ua2vfpc" 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="zfxvmsq" 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="v7p77lj" 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>

                            主站蜘蛛池模板: 执业药师报名条件,考试时间,考试真题,报名入口—首页 | 氟氨基酮、氯硝柳胺、2-氟苯甲酸、异香兰素-新晨化工 | PE一体化污水处理设备_地埋式生活污水净化槽定制厂家-岩康塑业 | 南京交通事故律师-专打交通事故的南京律师 | SPC工作站-连杆综合检具-表盘气动量仪-内孔缺陷检测仪-杭州朗多检测仪器有限公司 | 无纺布包装机|径向缠绕包装机|缠绕膜打包机-上海晏陵智能设备有限公司 | 有源电力滤波装置-电力有源滤波器-低压穿排电流互感器|安科瑞 | 牛奶检测仪-乳成分分析仪-北京海谊 | 排烟防火阀-消防排烟风机-正压送风口-厂家-价格-哪家好-德州鑫港旺通风设备有限公司 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 武汉印刷厂-不干胶标签印刷厂-武汉不干胶印刷-武汉标签印刷厂-武汉标签制作 - 善进特种标签印刷厂 | 全国国际化学校_国际高中招生_一站式升学择校服务-国际学校网 | 包塑软管|金属软管|包塑金属软管-闵彬管业 | 高中学习网-高考生信息学习必备平台| LED灯杆屏_LED广告机_户外LED广告机_智慧灯杆_智慧路灯-太龙智显科技(深圳)有限公司 | 短信通106短信接口验证码接口群发平台_国际短信接口验证码接口群发平台-速度网络有限公司 | 烟台条码打印机_烟台条码扫描器_烟台碳带_烟台数据采集终端_烟台斑马打印机-金鹏电子-金鹏电子 | 耐腐蚀泵,耐腐蚀真空泵,玻璃钢真空泵-淄博华舜耐腐蚀真空泵有限公司 | 广东泵阀展|阀门展-广东国际泵管阀展览会 | 西子馋火锅鸡加盟-太原市龙城酉鼎餐饮管理有限公司 | 航空铝型材,7系铝型材挤压,硬质阳*氧化-余润铝制品 | 金蝶帐无忧|云代账软件|智能财税软件|会计代账公司专用软件 | 喷砂机厂家_自动除锈抛丸机价格-成都泰盛吉自动化喷砂设备 | 防腐储罐_塑料储罐_PE储罐厂家_淄博富邦滚塑防腐设备科技有限公司 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 优秀的临床医学知识库,临床知识库,医疗知识库,满足电子病历四级要求,免费试用 | 电子元器件呆滞料_元器件临期库存清仓尾料_尾料优选现货采购处理交易商城 | 缓蚀除垢剂_循环水阻垢剂_反渗透锅炉阻垢剂_有机硫化物-郑州威大水处理材料有限公司 | 上海办公室装修公司_办公室设计_直营办公装修-羚志悦装 | 阴离子聚丙烯酰胺价格_PAM_高分子聚丙烯酰胺厂家-河南泰航净水材料有限公司 | 无纺布包装机|径向缠绕包装机|缠绕膜打包机-上海晏陵智能设备有限公司 | 山东螺杆空压机,烟台空压机,烟台开山空压机-烟台开山机电设备有限公司 | 焊锡丝|焊锡条|无铅锡条|无铅锡丝|无铅焊锡线|低温锡膏-深圳市川崎锡业科技有限公司 | 氧化锆陶瓷_氧化锆陶瓷加工_氧化锆陶瓷生产厂家-康柏工业陶瓷有限公司 | 河南不锈钢水箱_地埋水箱_镀锌板水箱_消防水箱厂家-河南联固供水设备有限公司 | 球磨机 选矿球磨机 棒磨机 浮选机 分级机 选矿设备厂家 | 耐酸泵,耐腐蚀真空泵,耐酸真空泵-淄博华舜耐腐蚀真空泵有限公司 精密模具-双色注塑模具加工-深圳铭洋宇通 | 别墅图纸超市|别墅设计图纸|农村房屋设计图|农村自建房|别墅设计图纸及效果图大全 | 广州各区危化证办理_危险化学品经营许可证代办 | 通辽信息港 - 免费发布房产、招聘、求职、二手、商铺等信息 www.tlxxg.net | 防爆电机生产厂家,YBK3电动机,YBX3系列防爆电机,YBX4节防爆电机--河南省南洋防爆电机有限公司 |