public static String getLargerString(ResultSet rs, int columnIndex) throws SQLException {
InputStream in = null;
int BUFFER_SIZE = 1024;
try {
in = rs.getAsciiStream(columnIndex);
if (in == null) {
return "";
}
byte[] arr = new byte[BUFFER_SIZE];
StringBuffer buffer = new StringBuffer();
int numRead = in.read(arr);
while (numRead != -1) {
buffer.append(new String(arr, 0, numRead));
numRead = in.read(arr);
}
return buffer.toString();
} catch (Exception e) {
e.printStackTrace();
throw new SQLException(e.getMessage());
}
}
|