java如何在中选择具有CLOB数据类型的列
我的jsp页面上有一个表,其中的一列由CLOB类型的数据库列填充。我在做这件事时遇到了一些麻烦,也看到了其他关于这件事的问题,但答案对我来说并不适用。以下是我的声明,其中的评论是CLOB
stmt = conn.prepareStatement("SELECT DISTINCT restriction, person, start_date, end_date, comments "
+ " FROM restrictions WHERE person = ? "
+ " AND (start_date BETWEEN TO_DATE (? , 'yyyy/mm/dd') AND TO_DATE (? , 'yyyy/mm/dd') "
+ " OR start_date < TO_DATE (? , 'yyyy/mm/dd') AND end_date IS NULL) " );
stmt.setString(1, Id);
stmt.setString(2, StartRest);
stmt.setString(3, EndRest);
stmt.setString(4, EndRest);
result = stmt.executeQuery();
然后我将在while循环中设置列:
while (result.next()) {
restrictions = StringUtils.defaultString(result.getString("str_restriction"));
.......
// here is where I would get my Clob data from the query.
因此,基本上,我想知道是否有一种方法可以翻译查询中的CLOB,甚至是java代码中的CLOB,这样它就可以在我的页面中使用
# 1 楼答案
问题来自查询的distint子句,它不能应用于CLOB
检查是否确实需要distinct关键字。或者您可以将查询重写为
PS:下次,在问题中包括错误消息和您的数据库。我已经能够通过简单的谷歌搜索“ora-00932 clob”找到问题所在