【问题标题】:How can insert BFILE values in oracle using java?如何使用 java 在 oracle 中插入 BFILE 值?
【发布时间】:2016-04-04 15:10:43
【问题描述】:

我正在尝试使用以下 java 程序创建插入 BFILE 数据类型值的示例。

   public class ImportDriver
{
    public static void main (String args [])
            throws Exception
    {
        // Load the Oracle JDBC driver:
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

        // Connect to the database:
        Connection conn =
                DriverManager.getConnection ("jdbc:oracle:thin:@localhost:oracledb", "User1", "password");
        conn.setAutoCommit (false);
        Statement stmt = conn.createStatement ();       

        try
        {          

            stmt.execute ("insert into test_dir_table values ('test', bfilename ('C:\\temp\\TEST_DIR', 'file1'))");
            stmt.execute ("insert into test_dir_table values ('test2', bfilename ('C:\\temp\\TEST_DIR', 'file6'))");
            stmt.execute ("insert into test_dir_table values ('test1', bfilename ('TEST_DIR', 'file2.gif'))");
            // Commit the transaction:
            conn.commit();
            stmt.close();
            conn.close();
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
    }
}

通过使用上述程序值被插入到表中,但是当我使用 oracle 开发工具看到 BFILE 的值时,插入的图像没有显示。

请建议如何使用 java 程序将 BFILE 值插入表中?

【问题讨论】:

    标签: java oracle


    【解决方案1】:

    您可以使用 oracle.sql 包中的方法来处理 BFILE 类型 here is the documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-01
      • 1970-01-01
      • 2017-02-22
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多