File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Conversion into SQL Result Clob from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Conversion into SQL Result Clob from a String " Watch "Conversion into SQL Result Clob from a String " New topic
Author

Conversion into SQL Result Clob from a String

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
I am not using any prepared statement

i am using Simple Query

Query can take 4000 Characters of String at one time

I have data over 10 thousand characters

I take an array of 4000's and put query process in loop

I feel i am going on wrong side.

I tried to used Oracle Resultset before but unable to get result through it, i am unable to get any other example over Google search


I am using JDK 6, Oracle Database



Regards
Azrael Noor
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1106

using the search
java sql insert clob oracle I found this:
http://stackoverflow.com/questions/5549450/java-how-to-insert-clob-into-oracle-database
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
For All Examples i am getting the same

also got same before when i previously tried the, but due to time lapse i inserted logic mentioned in first post.



Could you please tell how to resolve this?




Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3436
    
  47

I've described how I've implemented inserting BLOBs into Oracle database some time ago here:
http://www.coderanch.com/forums/posts/list/513175#2322695
http://www.coderanch.com/forums/posts/list/518509#2347822

It should be easy to modify it to store CLOBs instead of BLOBs, but if you still have problems, feel free to ask again. Note that this solution is Oracle specific. There should be a database-agnostic way to put LOBs into database, but I didn't need that yet so I've only used this (Oracle specific) one.
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
I am looking onto your example

i now picked OJDBC6 Jar file, i think i was using old one OBDBC14

Compiling Same code and error changed






If anyone get this please suggest
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3436
    
  47

Change your sqlStr variable to this:

The "for update" clause will lock the row. It is necessary condition in Oracle to lock row before you modify the LOB; it is documented somewhere. It was not in my code, because there the row gets locked when it is updated.
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
Martin Martin Martin Martin





Thanks It work Successfully Now

JAR: OJDBC6
JDK: 1.6
Code:



Is their any other approach to achieve this?



Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3436
    
  47

You're welcome!

The approaches I posted before are very similar to what you've got now. There might be slight performance saving with them if you're uploading large CLOBs, or lots and lots of small ones. Otherwise it is probably not worth the hassle, if you're satisfied with your current solution.
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
In Present the data is appending to data which i am retrieving in first query.
Just looking around to empty CLOB object.

I will also look on your examples, and make through them too and ask you again on them, if any problem still persists
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 378
The Driver is working fine is updating data for 30 Thousand characters.

I am now implementing the above like this

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conversion into SQL Result Clob from a String
 
Similar Threads
ORACLE JDBC ERROR ORA-00600
Concatination 3 columns of VARCHAR2(4000) to return a ResultSet with one column
String to CLOB conversion
Storing Kanji charaters into database
Bean that throws exceptions are not handled in JSP[solved]