This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JDBC and the fly likes Writing a Clob in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Writing a Clob in Java" Watch "Writing a Clob in Java" New topic
Author

Writing a Clob in Java

Christa Koch
Greenhorn

Joined: Dec 06, 2005
Posts: 5
In the application I'm reviewing a clob is written like this:

- insert a row with an empty clob (with EMPTY_CLOB())
- select the clob-column with the empty clob to get the lob locator
- update the row to write the new clob with "meaningful" data

Now I'm told that performance is better when the lob locator is returned by the insert statement. I know that the syntax for the sql is like that:

insert into <table_name> (<attribute list> values(<attributes>,EMPTY_CLOB()) returning <clob column> into clob_selected;

Can anybody help me doing this in Java? I'd appreciate your help very much but don't be angry if I don't reply for hours on end. I'm in Germany and my working day is almost over...
Christa Koch
Greenhorn

Joined: Dec 06, 2005
Posts: 5
I'd like to add that the difficult part for me is the returning clause.
joseph edwards
Greenhorn

Joined: Nov 26, 2005
Posts: 12
THe performance will depend on the database. Are you using Oracle as the DB?

In Oracle, you may notice a performance benefit if you use the native Oracle Driver APIs to insert an empty clob first, and then update the CLOB afterwards.

However, in MySQL, inserting the CLOB directly may give you better performance.

Originally posted by Christa Koch:
In the application I'm reviewing a clob is written like this:

- insert a row with an empty clob (with EMPTY_CLOB())
- select the clob-column with the empty clob to get the lob locator
- update the row to write the new clob with "meaningful" data

Now I'm told that performance is better when the lob locator is returned by the insert statement. I know that the syntax for the sql is like that:

insert into <table_name> (<attribute list> values(<attributes>,EMPTY_CLOB()) returning <clob column> into clob_selected;

Can anybody help me doing this in Java? I'd appreciate your help very much but don't be angry if I don't reply for hours on end. I'm in Germany and my working day is almost over...
Christa Koch
Greenhorn

Joined: Dec 06, 2005
Posts: 5
Joseph, the database is Oracle.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Writing a Clob in Java