<tfoot id='pTgsj'></tfoot>

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

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

          <bdo id='pTgsj'></bdo><ul id='pTgsj'></ul>
        <legend id='pTgsj'><style id='pTgsj'><dir id='pTgsj'><q id='pTgsj'></q></dir></style></legend>
      1. 使用 Java 为 DB2 和 Oracle 插入 BLOB

        时间:2023-09-30
          • <small id='VOJis'></small><noframes id='VOJis'>

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

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

                • <bdo id='VOJis'></bdo><ul id='VOJis'></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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何为内存 HSQL 编写自定义函数 下一篇:通过 JDBC 连接到 DB2 时的用户名和密码

                  相关文章

                  最新文章

                  1. <tfoot id='5TQVX'></tfoot>

                    • <bdo id='5TQVX'></bdo><ul id='5TQVX'></ul>
                  2. <small id='5TQVX'></small><noframes id='5TQVX'>

                    <legend id='5TQVX'><style id='5TQVX'><dir id='5TQVX'><q id='5TQVX'></q></dir></style></legend>

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