The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
December 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Blob creating problem

Posted by Mathur on November 02, 2001 at 8:33 PM


Hi,

I tried to create a bolb using the way oracle told

istmt.setBinaryStream( 4, finalInStream, finalInStreamSize);

I am unable to create a blob bigger 3K. When I tried to place 6K
data in it, it placed an empty blob in the database and
gave me the following error
Error while running: java.sql.SQLException: No more data to read from socket

Can anyone help me??????

Thanks/Mathur

> please help to solve my problem to store String object into Database table having col of type BLOB.

> I have written this code.Change the Drivermanager.getConnection() method's accordingly
> It is giving SQLException during run time.
> Check it and solve it.
> mail me to supalc@macmetit.com


> The ins_blob procedure contains the insert statement to the table.
>
> Table creatinon sql script:
> =============
> create table
> files_org(val number, blb BLOB);
>
>
> Create Procedure follows:
> =========
> Create OR Replace procedure ins_blob(p_id in number,p_content BLOB)

> as

> l_blob blob;

> begin

> insert into files_org values( p_id, empty_blob() )

> returning content into l_blob;

> commit;

> --dbms_lob.writeappend ( l_blob,length(content), content);

> update files_org set content = p_content where file_id = p_id;

> commit;

> end;

>
> The Java Code follows:
> =======
> import oracle.jdbc.driver.*;
> import oracle.sql.*;
>

> public class tst
> {
>
> public static void main(String[] args) throws Exception
> {
>
> try
> {
> java.sql.Connection con = null;
> Class.forName("oracle.jdbc.driver.OracleDriver");//Registered the dr
> iver
> con = DriverManager.getConnection("jdbc:oracle:thin:@10.1.1.2:1521:M
> ACI","scott","tiger");
>

> /*********/
> String s = "Supal";
>
> oracle.sql.BLOB BL = new oracle.sql.BLOB((OracleConnection)con,s.getBytes());
> String sQuery = "begin " + "ins_blob" + "(?,?);end;";
> OracleCallableStatement rcProc = (OracleCallableStatement)con.prepar
> eCall(sQuery);
> rcProc.setInt(1,563);
> rcProc.setBLOB(2,BL);
> rcProc.execute();
>
> System.out.println("Insert successfully");
> }
> catch(SQLException e)
> {
> System.out.println("Exception occured: "+e);
> }
> catch(Exception e1)
> {
> System.out.println("Exception occured 1 : "+e1);
> }
> /***********/
> }
>
>
> SQLException is :
> =======
> Exception occured: java.sql.SQLException: ORA-24812: character set conversion to
> or from UCS2 failed
> ORA-06512: at "SCOTT.INS_BLOB", line 11
> ORA-06512: at line 1

>






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us