Java SQL ResultSet String Read getTrimmedStringToUpperCase(ResultSet rs, String columnLabel)

Here you can find the source of getTrimmedStringToUpperCase(ResultSet rs, String columnLabel)

Description

get Trimmed String To Upper Case

License

Apache License

Declaration

public static String getTrimmedStringToUpperCase(ResultSet rs, String columnLabel) throws SQLException 

Method Source Code

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

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

public class Main {
    public static String getTrimmedStringToUpperCase(ResultSet rs, String columnLabel) throws SQLException {
        return getString(rs, columnLabel) != null ? nullIfEmpty(getString(rs, columnLabel).toUpperCase()) : null;
    }//from w w w  .  j  a  v  a2 s  . com

    public static String getString(ResultSet rs, String columnLabel) throws SQLException {
        return rs.getString(columnLabel);
    }

    public static String nullIfEmpty(String text) {
        return cleanLongText(text);
    }

    public static String cleanLongText(String text) {
        if (text != null) {
            String trimmedText = text.trim();
            if (trimmedText.length() > 0) {
                return trimmedText;
            }
        }

        return null;
    }
}

Related

  1. getStringFromResultSetEmptyIsNull(ResultSet rset, String fieldName)
  2. getStringList(ResultSet resultSet, String columnName)
  3. getStringSuppressSQLException(final ResultSet rs, final String columnLabel)
  4. getStringUTF8(ResultSet rs, String which)
  5. getStringValue(final ResultSet rs, final int index)