「Java入門」clobデータを取得するコード
方法1
Clob clob = rs.getClob(“introName");//java.sql.Clob
String detailinfo = “";
if(clob != null){
detailinfo = clob.getSubString((long)1,(int)clob.length());
}
方法2
Clob clob = rs.getClob(“introName");//java.sql.Clob
int i = 0;
if(clob != null){
InputStream input = clob.getAsciiStream();
int len = (int)clob.length();
byte by[] = new byte[len];
while(-1 != (i = input.read(by, 0, by.length))){
input.read(by, 0, i);
}
detailinfo = new String(by, “utf-8");
}
方法3
Clob clob = rs.getClob(“introName");//java.sql.Clob
String value="";
String line="";
if(clob!=null){
Reader reader=((oracle.sql.CLOB)clob).getCharacterStream();
BufferedReader br=new BufferedReader(reader);
while((line=br.readLine())!=null){
value += line + “\r\n";
}
}