Menu

#719 java.lang.ClassCastException: net.sourceforge.jtds.jdbc.ClobImpl cannot be cast to java.lang.String with varchar(MAX)

v1.2
open
nobody
None
1
2014-11-20
2013-11-29
MattD
No

I noticed this while using jTDS 1.2.8. It might impact 1.3.1 as well.

I have a column set to varchar(MAX) NOT NULL.
I tried to retrieve the column from a ResultSet using the getObject() method to retrieve the column value and casted the result to a String.

It resulted in a java.lang.ClassCastException: net.sourceforge.jtds.jdbc.ClobImpl cannot be cast to java.lang.String.

I've tried other JDBC drivers such as i-net and Microsoft's without any issues.

Let me know if you have any questions.

Thanks,

Matt

Discussion

  • MattD

    MattD - 2013-11-29

    Note that if you switch (String) rs.getObject("column") to rs.getString("column") it works fine, but you shouldn't get an exception from doing it the other way I wouldn't think.

     
  • MattD

    MattD - 2013-12-03

    Actually, it looks like all I needed was uselobs=false in this case and I don't have to change anything. Sorry for the confusion.

     

Log in to post a comment.