This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to convert a String to java.sql.Clob? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to convert a String to java.sql.Clob?" Watch "How to convert a String to java.sql.Clob?" New topic
Author

How to convert a String to java.sql.Clob?

qionghua yang
Ranch Hand

Joined: Oct 31, 2000
Posts: 68
Hi there,
I would like to convert a String variable to the java.sql.Clob datatype:
My code looks like this:
String streamHTML = (out.toString());
Clob outHTML = (Clob)streamHTML;
And of course, this code doesn't work. Hope you can help me.
Thanks a lot.
qionghua
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
I am having the same problem i wish i knew how to do that
what enviorment are you using?
qionghua yang
Ranch Hand

Joined: Oct 31, 2000
Posts: 68
Window NT with Informix database. How about you?
qionghua
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
windows NT visual Age for java and an oracle database
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
Fred,
How are trying to insert/update oracle?
Can I see some code?
Dan
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
Have either of you tried
getCharacterStream()
getAsciiStream()
???
Dan
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
Dan
my problem is i am using visual age for java and therefore do not hvae a handle on the result set
I wrote some code outside of VA and it works fine
golfing numty
Greenhorn

Joined: Jul 16, 2013
Posts: 1
create clob from string for Oracle

oracle.sql.CLOB tempclob = oracle.sql.CLOB.createTemporary(
// the connection used to
// create the clob
// has to be the same as is
// used for the update
updatestmt.getConnection(), false,
oracle.sql.CLOB.DURATION_SESSION);
String clobstring = "yourdata";
try {
tempclob.setString(1, clobstring);
} catch (SQLException ex2) {


}


for non Oracle

if you have original clob data from a select
java.sql.Clob c = (java.sql.Clob) orig;
c.setString(1, "yourdata");
updatestmt.setClob(updateindex, c);

if original clob data is null - don't use clob - just use
updatestmt.setObject(updateindex, "yourdata");









 
Don't get me started about those stupid light bulbs.
 
subject: How to convert a String to java.sql.Clob?
 
Similar Threads
How to Convert a java.sql.CLOB object to String
How to convert a String to java.sql.Clob?
String to CLOB conversion
Clob to String (Using Hibernate)
How to convert a java.sql.CLOB object to String