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 -> Oracle BLOB Insert using createTemporary

Oracle BLOB Insert using createTemporary

From: Malkit <mbhasin_at_gmail.com>
Date: 30 Nov 2004 18:40:37 -0800
Message-ID: <c88b423b.0411301840.4b17202f@posting.google.com>


Hi,

I need to insert BLOB data into database creating temporary BLOB using createTemporary. I found this piece of code for writing to clob

import java.sql.*;
import java.util.*;
import java.text.*;
 
/* -------------------------------------------------------------------

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

        try {  

            DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

            Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@server:1521:sid", "uid", "pwd");  

            PreparedStatement ps = conn.prepareStatement("INSERT INTO CLOBTABLE VALUES (?)");

            
            oracle.sql.CLOB newClob =

oracle.sql.CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_CALL);
            
            newClob.putString(1,"This string, up to 4 gigabytes will
be inserted into the CLOB");
        
            ps.setClob(1, newClob);
         
            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());
        }

    }
 }

But when i try the following for BLOB it throws exception the exception
"Java Exception caught, error message=ORA-22275: invalid LOB locator specified"


            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.setBytes(str.getBytes());
          
            ps.setBlob(1, newBlob);
            
            int rowcnt = ps.executeUpdate();

-----------------

I am using oracle 9.2 and java 1.4 and ojdbc14.jar

I would really appreciate any help.

Thanks.

Malkit Received on Tue Nov 30 2004 - 20:40:37 CST

Original text of this message

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