#1
  1. No Profile Picture
    elvis
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    28
    Rep Power
    0

    how to insert bitmap into Oracle8i using java


    hi all,
    Is there anyone know how to insert a bitmap file size 596KB into oracle8i using Java via preapred statement?
    I created a table with two BLOB columns and some other VARCHAR2 columns. But uncertain on how to insert bitmap in oracle via preparedStatement.
    I used to insert the bitmap into PGSQL, bytea data type. How to do it in oracle8i?
    BFILE is not advisable in my application. Because it required operating system i/o.

    pls helps...
    regards
    elvis
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    68
    Rep Power
    12
    Here is a proc of mine in which I use the PreparedStatement class:

    private static void insertDB (String category, String subCategory, String action, String count,String percentage, String name, String timeZone, int begin, int end) throws java.sql.SQLException
    {

    String d = quotedString(extractDateFromFilename(inputFileName));

    String s = "insert into Voice_Metrics values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, to_date(" + d + ",'YYYYMMDD'), sysdate)";

    PreparedStatement pstmt = conn.prepareStatement(s);


    pstmt.setString(1,category);
    pstmt.setString(2,subCategory);
    pstmt.setString(3,action);
    pstmt.setString(4,count);
    pstmt.setString(5,percentage);
    pstmt.setString(6,name);
    pstmt.setString(7,timeZone);
    pstmt.setInt(8,begin);
    pstmt.setInt(9,end);
    pstmt.setString(10,inputFile);

    int r = pstmt.executeUpdate();

    }



    About the blob data type - I just tried:

    create table myTable (
    bb blob
    );

    insert into myTable (bb) values ('ff00123213ff00ffaa');

    It seems that Oracle expects the blob value to be encoded as hex string, because when I tried:

    insert into myTable (bb) values ('Q');

    I got: ORA-01465: invalid hex number

    Regards,
    Dan

IMN logo majestic logo threadwatch logo seochat tools logo