com.evanmclean.evlib.sql
Class Rs

java.lang.Object
  extended by com.evanmclean.evlib.sql.Rs

public final class Rs
extends Object

A bunch of static utility functions related to result sets.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Method Summary
static Double getDouble(ResultSet rs, int col_idx)
          Retrieves a double from a result set, checking for null.
static Double getDouble(ResultSet rs, String col_name)
          Retrieves a double from a result set, checking for null.
static Integer getInt(ResultSet rs, int col_idx)
          Retrieves an integer from a result set, checking for null.
static Integer getInt(ResultSet rs, String col_name)
          Retrieves an integer from a result set, checking for null.
static Integer getIntZN(ResultSet rs, int col_idx)
          Retrieves an integer from a result set, nulls and zeros return null.
static Integer getIntZN(ResultSet rs, String col_name)
          Retrieves an integer from a result set, nulls and zeros return null.
static String getTrimString(ResultSet rs, int col_idx)
          Retrieves a trimmed string from a result set.
static String getTrimString(ResultSet rs, String col_name)
          Retrieves a trimmed string from a result set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDouble

public static Double getDouble(ResultSet rs,
                               int col_idx)
                        throws SQLException
Retrieves a double from a result set, checking for null.

Parameters:
rs - The result set.
col_idx - The index of the column to retrieve.
Returns:
Null if the column was null, or the value of the column.
Throws:
SQLException

getDouble

public static Double getDouble(ResultSet rs,
                               String col_name)
                        throws SQLException
Retrieves a double from a result set, checking for null.

Parameters:
rs - The result set.
col_name - The name of the column to retrieve.
Returns:
Null if the column was null, or the value of the column.
Throws:
SQLException

getInt

public static Integer getInt(ResultSet rs,
                             int col_idx)
                      throws SQLException
Retrieves an integer from a result set, checking for null.

Parameters:
rs - The result set.
col_idx - The index of the column to retrieve.
Returns:
Null if the column was null, or the value of the column.
Throws:
SQLException

getInt

public static Integer getInt(ResultSet rs,
                             String col_name)
                      throws SQLException
Retrieves an integer from a result set, checking for null.

Parameters:
rs - The result set.
col_name - The name of the column to retrieve.
Returns:
Null if the column was null, or the value of the column.
Throws:
SQLException

getIntZN

public static Integer getIntZN(ResultSet rs,
                               int col_idx)
                        throws SQLException
Retrieves an integer from a result set, nulls and zeros return null.

Parameters:
rs - The result set.
col_idx - The index of the column to retrieve.
Returns:
Null if the column was null or zero, or the value of the column.
Throws:
SQLException

getIntZN

public static Integer getIntZN(ResultSet rs,
                               String col_name)
                        throws SQLException
Retrieves an integer from a result set, nulls and zeros return null.

Parameters:
rs - The result set.
col_name - The name of the column to retrieve.
Returns:
Null if the column was null or zero, or the value of the column.
Throws:
SQLException

getTrimString

public static String getTrimString(ResultSet rs,
                                   int col_idx)
                            throws SQLException
Retrieves a trimmed string from a result set. Null returns an empty string.

Parameters:
rs - The result set.
col_idx - The index of the column to retrieve.
Returns:
The trimmed string.
Throws:
SQLException

getTrimString

public static String getTrimString(ResultSet rs,
                                   String col_name)
                            throws SQLException
Retrieves a trimmed string from a result set. Null returns an empty string.

Parameters:
rs - The result set.
col_name - The name of the column to retrieve.
Returns:
The trimmed string.
Throws:
SQLException