Java SQL ResultSet String Read getStringFromResultSetEmptyIsNull(ResultSet rset, String fieldName)

Here you can find the source of getStringFromResultSetEmptyIsNull(ResultSet rset, String fieldName)

Description

get String From Result Set Empty Is Null

License

Open Source License

Declaration

public static String getStringFromResultSetEmptyIsNull(ResultSet rset, String fieldName) throws SQLException 

Method Source Code

//package com.java2s;
/**//from  w w w .  j  av  a2 s.co m
 Copyright (c) 2013, Amit Lieberman
All rights reserved.
    
           GNU LESSER GENERAL PUBLIC LICENSE
               Version 3, 29 June 2007
    
 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
    
    
  This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License
    
 * Created with love
 * User: shpandrak
 * Date: 10/20/12
 * Time: 10:37
 */

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

public class Main {
    public static String getStringFromResultSetEmptyIsNull(ResultSet rset, String fieldName) throws SQLException {
        String string = rset.getString(fieldName);
        if (string != null && string.isEmpty())
            return null;
        return string;
    }

    public static String getStringFromResultSetEmptyIsNull(ResultSet rset, int column) throws SQLException {
        String string = rset.getString(column);
        if (string != null && string.isEmpty())
            return null;
        return string;
    }
}

Related

  1. getString(ResultSet rs, String columnLabel)
  2. getString(ResultSet rs, String columnName)
  3. getString(ResultSet rs, String name)
  4. getString(ResultSet rs, String name, String ifnull)
  5. getStringChunks(ResultSet rs, int colIndex, StringBuffer buf)
  6. getStringList(ResultSet resultSet, String columnName)
  7. getStringSuppressSQLException(final ResultSet rs, final String columnLabel)
  8. getStringUTF8(ResultSet rs, String which)
  9. getStringValue(final ResultSet rs, final int index)