Java SQL ResultSet String Read getString(ResultSet p_rset, int p_col)

Here you can find the source of getString(ResultSet p_rset, int p_col)

Description

static method for handling positional column gets for String values

License

Open Source License

Parameter

Parameter Description
p_rset ResultSet object on which to perform get
p_col int representing the column position in the ResultSet

Return

String containing the value at p_col, otherwise NULL

Declaration

public static final String getString(ResultSet p_rset, int p_col) 

Method Source Code

//package com.java2s;
/**//from   w w  w.j  a  v a2s .  c o  m
 * Database functionality abstraction utilities.
 *
 * Supported drivers:
 * - Oracle
 * - PostgreSQL
 * - MySQL (incomplete)
 * - hsql DB (incomplete)
 * - DB2 (incomplete)
 *
 * Copyright (c) 2001-2004 Marc Lavergne. All rights reserved.
 *
 * The following products are free software; Licensee can redistribute and/or 
 * modify them under the terms of   the GNU Lesser General Public License
 * (http://www.gnu.org/copyleft/lesser.html) as published by the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-   1307  USA; 
 * either version 2.1 of the   license, or any later version:
 */

import java.sql.*;

public class Main {
    /**
     * static method for handling positional column gets for String values
     * @param p_rset ResultSet object on which to perform get
     * @param p_col int representing the column position in the ResultSet
     * @return String containing the value at p_col, otherwise NULL
     */
    public static final String getString(ResultSet p_rset, int p_col) {
        try {
            return p_rset.getString(p_col);
        } catch (SQLException e_sql) {
            return null;
        }
    }
}

Related

  1. getString(ResultSet res, String name)
  2. getString(ResultSet resultSet, String columnName)
  3. getString(ResultSet resultSet, String columnName)
  4. getString(ResultSet rs, int index, boolean trim)