Get a Long Text Column/Field from a Database : Long Text « Database « Java Tutorial






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());
    }
  }








20.23.Long Text
20.23.1.Get a Long Text Column/Field from a Database
20.23.2.How do you Store a Long Text Field in a Database?