[英]Spring SqlRowSet getting Clob as String using JdbcTemplate
I have a QUERY
column of type CLOB
in database. 我在数据库中有一个
CLOB
类型的QUERY
列。
I am reading it in my program as: 我在程序中将其读取为:
SqlRowSet myRowSet = this.jdbcTemplate.queryForRowSet(this.sqlQuery);
while(myRowSet.next()){
String currentClobString = myRowSet.getString("QUERY")
System.out.println(currentClobString);
}
But this is giving the below output: 但这给出了以下输出:
javax.sql.rowset.serial.SerialClob@7cfe7cfe
How can I correct this? 我该如何纠正?
Thanks for reading! 谢谢阅读!
You can call getObject(String columnLabel) method and use the IOutils from apache commons. 您可以调用getObject(String columnLabel)方法并使用来自Apache Commons的IOutils。 This sample code is taken from another SO response.
该示例代码来自另一个SO响应。
InputStream in = clobObject.getAsciiStream();
StringWriter w = new StringWriter();
IOUtils.copy(in, w);
String clobAsString = w.toString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.