Way to Handle CLOB

wxdqz

New Member
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("INSERTINTO YOURTABLE VALUES (?)");//The column is a CLOB columnps.setBinaryStream(3,new StringBufferInputStream(str),str.length());ps.executeUpdate();}catch(Exception e){System.out.println(e.getMessage());e.printStackTrace();}}CheersSyed Zulfiqar"Paul Clapham" <[email protected]> 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 <[email protected]> wrote in message>news:[email protected]...>>>> Hi,>> I haven't worked with CLOB but I think u don磘 create a clob directly>out>> of some String, instead you first create a pointer to the column to which>> you wan磘 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 thereand>> read it into some outputstream.>>>> Hope this may give some clear understanding.>>>> Regards>> syed zulfiqar>>>>>>>> "reuben" <[email protected]> wrote:>> >>> >hi,>> >i would like to insert a huge string value from my java servelet intoan>> >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.>> >>>>>
 
Top