case Types.LONGVARBINARY:
case Types.LONGVARCHAR:
try {
return resultSet.getString(index);
} catch (SQLException x) {
Reader in = resultSet.getCharacterStream(index);
char[] buffer = new char[2048];
int read = 0;
int r = 0;
while ((r = in.read(buffer, read, buffer.length - read)) > -1) {
read += r;
if (read == buffer.length) {
// grow input buffer
char[] newBuffer = new char[buffer.length * 2];
System.arraycopy(buffer, 0, newBuffer, 0,
buffer.length);
buffer = newBuffer;
}
}
return new String(buffer, 0, read);
}
case Types.DATE:
case Types.TIME:
case Types.TIMESTAMP:
return resultSet.getTimestamp(index);
case Types.NULL:
return null;
case Types.CLOB:
Clob cl = resultSet.getClob(index);
if (cl == null) {
return null;
}
char[] c = new char[(int) cl.length()];
Reader isr = cl.getCharacterStream();
isr.read(c);
return String.copyValueOf(c);
default:
return resultSet.getString(index);
}