I wonder what am I doing wrong in the scenario described below. I assessing some SQL Server versions for a project, and playing around with different DB types in a simple Java setting. I use Eclipse, Java 6 (1.6u45), driver sqljdbc4.jar, Sql Server 2012 (default installation), Windows 7, and I'm trying to write and read back from a test database/table different DB types. For columns of type NVARCHAR(n or max) and/or VARCHAR(n or max) write to DB using setClob() and setCharacterStream() methods without any problems. But, when I try to read back the Clobs I can only use getCharacterStream(). For reasons that I cannot understand I cannot use getClob() with either of the DB types listed above. I get the following exception stack:
com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from varchar to CLOB is unsupported.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:1117)
at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:2419)
at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:176)
at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:113)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1981)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1966)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getClob(SQLServerResultSet.java:2488)
at main.com.test.Test.main(Test.java:77)
I could not find any reference for this exception. MS documentation claims that getClob() is supported for NVARCAHR/VARCHAR columns. Code is very simple, one insert and then "Select * from table" and then positional resultset.getxxx(position) calls. Thanks in advance for any suggestion or ideas.