| Author |
Java program to Convert java.lang.String to java.sql.CLOB Object
|
anilellendula kumar
Ranch Hand
Joined: Jul 12, 2005
Posts: 43
|
|
Hai! i am getting xml data as a string contain morethan 4kb size i am using thin driver oracle 9i database pls provide java programme to convert String to the java.sql.clob (not oracle.sql.clob)object to insert data in DB Table
|
 |
anilellendula kumar
Ranch Hand
Joined: Jul 12, 2005
Posts: 43
|
|
here i tried with below code long l=0; oracle.sql.CLOB clobdocument=null; try { Writer wr=clobdocument.setCharacterStream(l); BufferedWriter br = new BufferedWriter(wr); StringReader strrd=new StringReader(data); char aux; do{ aux=(char)strrd.read(); br.write(aux); }while(aux != -1); Giving Error java.lang.reflect.InvocationTargetException: oracle.sql.CLOB.setCharacterStream(J)Ljava/io/Writer; can anybobdy help how to Rectify this Problem,if my approach is wrong help me how convert String to Clob Object
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
java.sql.Clob is an interface so you can't instantiate it. I would use stmt.setAsciiStream rather than trying to create a CLOB. That way you don't have to use database specific code. It will still be stored as a CLOB in the database.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
anilellendula kumar
Ranch Hand
Joined: Jul 12, 2005
Posts: 43
|
|
|
My client requirement is to convert it to CLOB from string data and store in DB Table,can provide me logic to create CLOB object
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
Originally posted by anilellendula kumar: My client requirement is to convert it to CLOB from string data and store in DB Table,can provide me logic to create CLOB object
I think your client meant it should be stored as a CLOB in the database. How you go about that is an implementation detail.
|
 |
Rohit Dhingraaa
Greenhorn
Joined: Jul 10, 2011
Posts: 4
|
|
Hi All,
I need to pass the Clob object in my junit test case to check the functionality.
How should I create the same?
Regards
Rohit Dhingra
|
 |
 |
|
|
subject: Java program to Convert java.lang.String to java.sql.CLOB Object
|
|
|