I'm having some problem to get a Clob field using java. So this is what I've done:
String
sql = ("SELECT DBMS_LOB.substr(LDTEXT, 1000) AS TEXT "
+ "FROM LONGDESCRIPTION ");
try (Connection connection = BDOracle.abreConexaoDB2();
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(sql);
) {
while (resultSet.next()) {
It breaks here:
Clob clob = (Clob) resultSet.getClob("TEXT");
long length = clob.length();
String out = clob.getSubString(1, (int) length);
}
} catch (SQLException err) {
System.out.println(err.getMessage());
}
Exception returns:
ERRORCODE=-4461, SQLSTATE=42815 [jcc][t4][1092][11644][3.53.70] invalid data conversion wrong result column type for requested conversion.
The query works fine on the database, I'm using DB2.