Hibernate custom type to avoid 'Caused by: java.sql.SQLException: Stream has already been closed'

前端 未结 4 1296
小蘑菇
小蘑菇 2021-02-14 02:40

How do I write a custom Long class to handle long values in Oracle, to avoid the following error?

Caused by: java.sql.SQLException: Stream has already bee

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 03:00

    I think you get this message when you try to get an Oracle LONG value from the result set multiple times.

    I had code like:

            rs.getString(i+1) ;
            if (rs.wasNull()) continue ;
    
            set(queryAttr[i], rs.getString(i+1)) ;
    

    And I started getting the "Stream has already been closed." error. I stopped getting the error when I changed the code to:

            String str = rs.getString(i+1) ;
            if (rs.wasNull()) continue ;
    
            set(queryAttr[i], str) ;
    

提交回复
热议问题