-
Way to Handle CLOB
Hi,
U Can handle CLOB as follows:
try
{
String str = "The String to be converted";
Class.forName("driver");
Connection conn = DriverManager.getConnection("url","username","password");
PreparedStatement ps = conn.prepareStatement("INSERT
INTO YOURTABLE VALUES (?)");
//The column is a CLOB column
ps.setBinaryStream(3,new StringBufferInputStream(str),str.length());
ps.executeUpdate();
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
Cheers
Syed Zulfiqar
"Paul Clapham" <pclapham@core-mark.com> wrote:
>When you look at the documentation for the Clob interface, it doesn't
>mention any methods for writing a stream into one. Reading a stream from
>one, yes, but not writing. The interface appears to be for read-only CLOBS,
>unless you can tell me the names of the methods that I didn't see.
>
>Syed Zulfiqar <query@edmail.com> wrote in message
>news:392a9330$1@news.devx.com...
>>
>> Hi,
>> I haven't worked with CLOB but I think u donīt create a clob directly
>out
>> of some String, instead you first create a pointer to the column to which
>> you wanīt to insert the CLOB into. That means that you first create an
>empty_clob
>> into the db. Then you fetch this empty clob from the db and finally you
>write
>> your stream into the clob. Vice versa if you would like to get the clob
>from
>> the db, You select the lob, then you create an inputstream from there
and
>> read it into some outputstream.
>>
>> Hope this may give some clear understanding.
>>
>> Regards
>> syed zulfiqar
>>
>>
>>
>> "reuben" <reubenjacob@hotmail.com> wrote:
>> >
>> >hi,
>> >i would like to insert a huge string value from my java servelet into
an
>> >oracle database. i have a clob field in the databse for this purpose.
>> >
>> >i am unable to convert the string value to clob. anu clues would be
>appreciated.
>> >
>> >thanx in advance.
>> >bye,
>> >reuben.
>> >
>>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks