Spring SqlRowSet使用JdbcTemplate将Clob作为字符串获取 [英] Spring SqlRowSet getting Clob as String using JdbcTemplate

查看:567
本文介绍了Spring SqlRowSet使用JdbcTemplate将Clob作为字符串获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有一个CLOB类型的QUERY列.

I have a QUERY column of type CLOB in database.

我在程序中将其读取为:

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);
}

但这给出了以下输出:

javax.sql.rowset.serial.SerialClob@7cfe7cfe

我该如何纠正?

感谢阅读!

推荐答案

您可以调用getObject(String columnLabel)方法并使用apache commons中的IOutils.该示例代码来自另一个SO响应.

You can call getObject(String columnLabel) method and use the IOutils from apache commons. This sample code is taken from another SO response.

    InputStream in = clobObject.getAsciiStream();
    StringWriter w = new StringWriter();
    IOUtils.copy(in, w);
    String clobAsString = w.toString();

这篇关于Spring SqlRowSet使用JdbcTemplate将Clob作为字符串获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆