File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Inserting CLOB(URGENT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Inserting CLOB(URGENT)" Watch "Inserting CLOB(URGENT)" New topic

Inserting CLOB(URGENT)

ram mohan
Ranch Hand

Joined: Oct 17, 2000
Posts: 68
Hi everybody,
This is urgent.I badly need the advice
I have to fill a form and update that supplied information to a table.Some informations in that form is a very lenghthy paragraph.So I defined those coluumns in the table as CLOB.
In the case of strings
private String Address;
Address=new String(request.getParameter("Address").trim());
stmt.execute("INSERT INTO TEST (ADDRESS) VALUES ('"+Address+"');");
The problem is how to insert those CLOB columns in the above sql?
I am using INTERBASE Database
How I have planned is I will get those lengthy string into the servlet as a string.Thereafter I thought of convert it in such a way so that I can directly insert it into the CLOB table.
How to convert the lengthy string into CLOB in the servlet.
I think what I have planned is correct.If it is wrong please correct me.
Since this is urgent I really appreciate speedy response.
I will appreciate comprehensive answer with the correct code
Thanks in advance
[This message has been edited by ram mohan (edited December 29, 2000).]
paul sun

Joined: Dec 22, 2000
Posts: 28
Sounds to use setAsciiStream() or setCharacterStream() of Statement methods.
ram mohan
Ranch Hand

Joined: Oct 17, 2000
Posts: 68
Thanks Paul.Your suggestion is excellent.I have succeeded
uma K

Joined: May 29, 2001
Posts: 5
I am facing a similar insertion problem into a CLOB column in the Oracle database. If I use direct INSERT statement, the setAsciiStream works fine. But if I user stored procedure for INSERT, then it gives as Type mismatch error. The data type is declared as CLOB in the IN parameter of the stored procedure
subject: Inserting CLOB(URGENT)
It's not a secret anymore!