• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clob and String

 
Signor Rana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Signor,
Why can't you just do rs.getString() when getting the value from the db?
 
Signor Rana
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rs.setString(ClobValue);
work when i am saving the data but rs.getString() is getting null ? when reading from db?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic