mybatis返回字段中存在clob类型的处理

数据库字段存在clob类型,通过mybatis返回时会返回clob类型

解决方案二:

1.在resultMap中添加jdbcType 和javaType 声明

    <resultMap column="content"  property="content"  jdbcType="CLOB" javaType="java.lang.String"></resultMap>

解决方案一:

1.需要在java代码中处理这个类型转为String

 

public String clobToString(Clob clob) throws SQLException,IOException{

     String resultString;

    try(

        Reader reader = clob.getCharacterStream();

        BufferedReader br = new BufferedReader(read)

    ){

        String s = br.readLine();

        StringBuilder sb = new StringBuilder();

         while(s!= null){

            sb.append(s);

            s = br.readLine();

        }

            resultString = sb.toString();

    }

    return = resultString;

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章