| Author |
Clob and String
|
Signor Rana
Greenhorn
Joined: Jan 24, 2004
Posts: 4
|
|
How can I convert read clob as a string ? I am selecting data from table which is clob data type, How I can I convert it into string. I can insert but nor read? any clue! Thanks
|
 |
Signor Rana
Greenhorn
Joined: Jan 24, 2004
Posts: 4
|
|
I did create method! import java.io.*; import java.lang.*; import java.sql.*; public class Clob2String { public Clob2String() { } public String convertClob2String(java.sql.Clob clobInData) { String stringClob = null; try { long i = 1; int clobLength = (int) clobInData.length(); stringClob = clobInData.getSubString(i, clobLength); } catch (Exception e) { System.out.println(e); } return stringClob; } }
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26151
|
|
Signor, Why can't you just do rs.getString() when getting the value from the db?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Signor Rana
Greenhorn
Joined: Jan 24, 2004
Posts: 4
|
|
rs.setString(ClobValue); work when i am saving the data but rs.getString() is getting null ? when reading from db?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26151
|
|
Signor, That's odd. I use getString() and it works. Are you sure the row has a value in it? Are you getting a null string? Try calling rs.wasNull() to see if the database thinks it has a null value.
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Clob and String
|
|
|