Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle BLOB Insert using createTemporary

Re: Oracle BLOB Insert using createTemporary

From: Malkit <mbhasin_at_gmail.com>
Date: 3 Dec 2004 12:51:05 -0800
Message-ID: <c88b423b.0412031251.7ec23be8@posting.google.com>


Well i found the solution, thought it might be useful to someone.



class TestOraBlobInsert {

    public static void main (String args []) throws SQLException {

        try {
            DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
            Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@malkit-1:1521:oracle92", "scott", "tiger");
            PreparedStatement ps = conn.prepareStatement("INSERT INTO
BLOBTABLE VALUES (?)");
            oracle.sql.BLOB newBlob =

oracle.sql.BLOB.createTemporary(conn, false, oracle.sql.BLOB.DURATION_CALL);

            String str = "This string, up to 4 gigabytes will be inserted into the BLOB";

          
            newBlob.putBytes(1, str.getBytes());
            ps.setBlob(1, newBlob);
            int rowcnt = ps.executeUpdate();
            System.out.println("Successful update of "+rowcnt+" row");
            ps.close();
            conn.close();            

}
catch (Exception e) { System.out.println("Java Exception caught, error message="+e.getMessage());
}

    }
}

Malkit Received on Fri Dec 03 2004 - 14:51:05 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US