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

      <tfoot id='QjOEa'></tfoot>

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

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

        使用 Java 为 DB2 和 Oracle 插入 BLOB

        Insert BLOB using java for both DB2 and Oracle(使用 Java 为 DB2 和 Oracle 插入 BLOB)

        1. <legend id='Cf4VQ'><style id='Cf4VQ'><dir id='Cf4VQ'><q id='Cf4VQ'></q></dir></style></legend>
            • <small id='Cf4VQ'></small><noframes id='Cf4VQ'>

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

                  <bdo id='Cf4VQ'></bdo><ul id='Cf4VQ'></ul>
                • 本文介绍了使用 Java 为 DB2 和 Oracle 插入 BLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前正在验证在 Oracle 上为 DB2 开发的应用程序.由于我们不想维护两个单独的源,我需要一些查询来将 blob 插入到字段中,这在 oracle 和 db2 中都可以使用.我没有任何标识符来区分应用程序在哪个数据库下运行.

                  I am currently validating an application developed on Oracle for DB2. Since we don't want to maintain two separate sources, I need some query to insert blob into a field, that works in both oracle and db2. I don't have any identifier to distinguish under which DB the application is running.

                  我在oracle中使用utl_raw.cast_to_raw,在DB2中使用CAST() as BLOB,两者互不兼容.

                  I used utl_raw.cast_to_raw in oracle and CAST() as BLOB in DB2 which are mutually incompatible.

                  推荐答案

                  您将无法找到使用某种类型转换的通用 SQL.但是您可以使用 JDBC 的 setBinaryStream()

                  You won't be able to find a common SQL that uses some kind of casting. But you can do this with "plain" SQL using JDBC's setBinaryStream()

                  PreparedStatement pstmt = connection.prepareStatement(
                     "insert into blob_table (id, blob_data) values (?, ?)";
                  
                  File blobFile = new File("your_document.pdf");
                  InputStream in = new FileInputStream(blobFile);
                  
                  pstmt.setInt(1, 42);
                  pstmt.setBinaryStream(2, in, (int)blobFile.length());
                  pstmt.executeUpdate();
                  connection.commit();
                  

                  您可以使用 setBinaryStream() 以与 UPDATE 语句相同的方式.

                  You can use setBinaryStream() the same way with an UPDATE statement.

                  这篇关于使用 Java 为 DB2 和 Oracle 插入 BLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

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

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