Java SQL ResultSet safeGetString(ResultSet r, String name)

Here you can find the source of safeGetString(ResultSet r, String name)

Description

safe Get String

License

Open Source License

Declaration

public static String safeGetString(ResultSet r, String name) 
            throws SQLException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2003, 2014 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * /*w ww  .  jav  a 2  s. c om*/
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

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

public class Main {
    public static final String EMPTY = "";

    public static String safeGetString(ResultSet r, String name) //
            throws SQLException {
        String s = r.getString(name);

        return (s != null) ? s : EMPTY;
    }
}

Related

  1. logCurrentResultSetRow(Log log, String msg, ResultSet rs)
  2. mapResultSet(ResultSet set)
  3. moveToPageNo(ResultSet rs, int pageNo, int pageSize)
  4. parseSqlResultToListMap(ResultSet rs)
  5. putResultSetToMap(final Hashtable map, final ResultSet resultSet, final String... keys)
  6. saveResultsetAsFile(ResultSet rs, String filePath, String fileName)
  7. toXML(ResultSet rs)
  8. writeResultSetToFile(String path, ResultSet results)