I am having a very strange problem to retrieve correctly data stored into an XMLType column through getAsciiStream(). My XMLs (fetched from an Oracle DB Oracle 11g Enterprise Edition Release 11.2.0.2.0 – 64bit) are larger than 32K.

I am using Java 1.5.0_22 and JDBC driver ojdbc5.jar.

If I fetch XML with only one reading cycle, I lose one character at about 32.000th position.

If I fetch XML with a second reading cycle, through this last, I can fetch it correctly: very strange.

If i REMOVE the first cicle, I lose one character!
–
MirkoMar 27 '12 at 10:10

I'm wondering whether Oracle is tripping over resultSet.getObject(2) != null in your while clause, is it possible that attempting to read the XMLType as an object truncates it at 32,000 characters? I'd remove the resultSet.getObject(2) from the while clause.
–
beny23Mar 27 '12 at 10:14

I tried your suggestion: while (true) { boolean res = resultSet.next(); if (!res) break; but the problem is not solved.
–
MirkoMar 27 '12 at 10:26