Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem while writing clob coulmn

 
hemant Budhewar BamniBk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which database ?

Please post some code and related error / log messages if any
 
hemant Budhewar BamniBk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can anybody havin answer for this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic