Java SQL Table Column readStringFromBlob(ResultSet resultSet, String columnLabel)

Here you can find the source of readStringFromBlob(ResultSet resultSet, String columnLabel)

Description

read String From Blob

License

Apache License

Declaration

public static String readStringFromBlob(ResultSet resultSet, String columnLabel) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.nio.charset.StandardCharsets;
import java.sql.Blob;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Main {
    public static String readStringFromBlob(ResultSet resultSet, String columnLabel) {
        try {//from ww w . j  a  v  a 2s . co  m
            Blob factoryBlob = resultSet.getBlob(columnLabel);
            return new String(factoryBlob.getBytes(1L, (int) factoryBlob.length()), StandardCharsets.UTF_8);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. lookupColumnIndex(ResultSetMetaData resultSetMetaData, String name)
  2. lookupColumnName(ResultSetMetaData resultSetMetaData, int columnIndex)
  3. printTableColumn(Connection conn, String sql)
  4. readMultiDouble(ResultSet resultSet, String columnName)
  5. readString(final ResultSet resultSet, final String columnName)
  6. resultSetAsCount(ResultSet rs, String countColumn)
  7. resultSetContainsColumn(ResultSet rs, String column)
  8. resultSetHasColumn(ResultSet rs, String sColumnName)
  9. resultSetToOneColumnAsCommamaSeparatedString(ResultSet rs)