aspose file tools*
The moose likes JDBC and the fly likes Problem while writing clob coulmn Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem while writing clob coulmn" Watch "Problem while writing clob coulmn" New topic
Author

Problem while writing clob coulmn

hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
Hi,

I am facing below problem,

I want to write clob column with some data. I have am writing it by following two step process,

1) Write empty string into clob cloumn with the help of EMPTY_CLOB() method
2) Get the recently added clob object and then update it by using writer (Resultset.getCharacterOutputStream)

This works fine for Statement but in case of Preparedstatment used in #1 it behaves strangely

Actually I found that it is not getting recently added clob object. So I could not able to update the column and data remain in clob column is empty.

Note: In case of Preparedstatment I am using batch processing.

Thanks in advance!

Thanks,
Hemant

Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Which database ?

Please post some code and related error / log messages if any


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
Deepak Bala wrote:Which database ?

Please post some code and related error / log messages if any


Thanks for your reply.

Stack: Oracle10g, Weblogic/Tomcat, Linux/Windows

I will add code as well.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You can follow these steps -> http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html

Let us know if you have errors even after following that tutorial
hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
Deepak Bala wrote:You can follow these steps -> http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html

Let us know if you have errors even after following that tutorial


I am sorry Deepak,

I have initially tried this code but I was getting problem while writing with help of pstmt.setString() for More than 4k characters.

In above case even if I use props.put("SetBigStringTryClob", "true"); still it says string literal too long.

So then I used the steps which I mentioned.

i.e.

Wrting Empty Clob first then updating with characterStream writer.

I read somewhere that SetBigStringTryClob flag works in case main not for web apps.

Please provide if you have any inputs.



hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
Deepak Bala wrote:You can follow these steps -> http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/handlingclobsinoraclejdbc10g.html

Let us know if you have errors even after following that tutorial


Code Snippet to update:

CLOB clob = (CLOB) objResultSetP.getObject(1);

Writer writer = null;
try
{
writer = clob.getCharacterOutputStream();
writer.write(m_strValue);
writer.flush();
}
finally
{
try
{
if (writer != null)
writer.close();
}

hemant Budhewar BamniBk
Ranch Hand

Joined: May 09, 2009
Posts: 33
Hi, can anybody havin answer for this?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while writing clob coulmn