jxUtil 0.6

org.sourceforge.jxutil.sql
Class SQLUtil

java.lang.Object
  |
  +--org.sourceforge.jxutil.sql.SQLUtil

public class SQLUtil
extends Object

Utility functions for JDBC access.


Nested Class Summary
static class SQLUtil.TypeInfoRow
           
 
Field Summary
(package private) static Map nameTypeMap
           
(package private) static Map typeNameMap
           
 
Constructor Summary
private SQLUtil()
          Cannot instantiate.
 
Method Summary
static String expandSQLState(String sqlState)
           
static Class[] getClasses(ResultSetMetaData meta)
          Get the column classes of a ResultSet.
static Class getClassFromType(int type)
          Map JDBC Types to Java Types.
static String[] getHeader(ResultSetMetaData meta)
          Get the column names of a ResultSet.
static String getName(int type)
          Get the String name of a java.sql.Types typecode.
static Class getOClassFromType(int type)
          Map JDBC Types to Java Object Types.
static String getTransactionName(int transaction)
          Get the literal String for a transaction code.
static int getType(String name)
          Get the java.sql.Types typecode given the name.
static int[] getTypeFromClass(Class cl)
          Map Java Types to JDBC Types.
static int[] getTypeFromOClass(Class cl)
          Map Java Object Types to JDBC Types.
static String makeLiteral(Object obj)
           
static Object[][] rs2Array(ResultSet set, boolean header)
          Fetch the data from a ResultSet in an array of Object.
static Object[] rs2Array2(ResultSet set)
          Make arrays of column names, column classes and data from a ResultSet.
static Collection rs2Collection(ResultSet set, boolean header, int col)
          Make a collection out of the values of one column of a ResultSet.
static Map rs2Map(ResultSet set)
          Return a one-row ResultSet as a Map.
static Map rs2Map(ResultSet set, int keyRow, int valRow)
          Return two columns of a ResultSet as a Map
static Map rs2Map12(ResultSet set)
          Return the first two columns of a ResultSet as a Map
static String[][] rs2StringArray(ResultSet set, boolean header)
          Fetch the data from a ResultSet into an array of String.
static String[] rs2StringArray(ResultSet set, boolean header, int col)
          Make an array of Strings out of the values of one column of a ResultSet.
static Collection rs2StringCollection(ResultSet set, boolean header, int col)
          Make a collection out of the values retrieved as String of one column of a ResultSet.
static void RSRow2Object(ResultSet set, Object obj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nameTypeMap

static Map nameTypeMap

typeNameMap

static Map typeNameMap
Constructor Detail

SQLUtil

private SQLUtil()
Cannot instantiate.

Method Detail

expandSQLState

public static String expandSQLState(String sqlState)

getClasses

public static Class[] getClasses(ResultSetMetaData meta)
                          throws SQLException
Get the column classes of a ResultSet.

SQLException

getClassFromType

public static Class getClassFromType(int type)
                              throws SQLException
Map JDBC Types to Java Types. Mapping according to Table B-1 of JDBC API 3.0 Specification.

SQLException
See Also:
Types

getHeader

public static String[] getHeader(ResultSetMetaData meta)
                          throws SQLException
Get the column names of a ResultSet.

SQLException

getName

public static String getName(int type)
Get the String name of a java.sql.Types typecode.


getOClassFromType

public static Class getOClassFromType(int type)
                               throws SQLException
Map JDBC Types to Java Object Types. Mapping according to Table B-3 of JDBC API 3.0 Specification.

SQLException
See Also:
Types

getTransactionName

public static String getTransactionName(int transaction)
Get the literal String for a transaction code.


getType

public static int getType(String name)
Get the java.sql.Types typecode given the name.


getTypeFromClass

public static int[] getTypeFromClass(Class cl)
                              throws SQLException
Map Java Types to JDBC Types. Mapping according to Table B-2 of JDBC API 3.0 Specification.

SQLException
See Also:
Types

getTypeFromOClass

public static int[] getTypeFromOClass(Class cl)
                               throws SQLException
Map Java Object Types to JDBC Types. Mapping according to Table B-4 of JDBC API 3.0 Specification.

SQLException
See Also:
Types

makeLiteral

public static String makeLiteral(Object obj)

rs2Array

public static Object[][] rs2Array(ResultSet set,
                                  boolean header)
                           throws SQLException
Fetch the data from a ResultSet in an array of Object. If header is given, the first row contains the column names.

SQLException

rs2Array2

public static Object[] rs2Array2(ResultSet set)
                          throws SQLException
Make arrays of column names, column classes and data from a ResultSet. The array returned will contain at index 0 an array of Strings with the header names, at index 1 an array of array of Object with the column data and at index 2 an array of Class with the column classes.

SQLException

rs2Collection

public static Collection rs2Collection(ResultSet set,
                                       boolean header,
                                       int col)
                                throws SQLException
Make a collection out of the values of one column of a ResultSet. If header is given, the first entry will contain the column name. The set will be at afterLast position.

SQLException

rs2Map

public static Map rs2Map(ResultSet set)
                  throws SQLException
Return a one-row ResultSet as a Map. The map will contain the column name as keys mapping to the corresponding row value.

SQLException

rs2Map

public static Map rs2Map(ResultSet set,
                         int keyRow,
                         int valRow)
                  throws SQLException
Return two columns of a ResultSet as a Map

SQLException

rs2Map12

public static Map rs2Map12(ResultSet set)
                    throws SQLException
Return the first two columns of a ResultSet as a Map

SQLException

rs2StringArray

public static String[][] rs2StringArray(ResultSet set,
                                        boolean header)
                                 throws SQLException
Fetch the data from a ResultSet into an array of String. If header is given, the first row contains the column names.

SQLException

rs2StringArray

public static String[] rs2StringArray(ResultSet set,
                                      boolean header,
                                      int col)
                               throws SQLException
Make an array of Strings out of the values of one column of a ResultSet. If header is given, the first entry will contain the column name.

SQLException

rs2StringCollection

public static Collection rs2StringCollection(ResultSet set,
                                             boolean header,
                                             int col)
                                      throws SQLException
Make a collection out of the values retrieved as String of one column of a ResultSet. If header is given, the first entry will contain the column name. The set will be at afterLast position.

SQLException

RSRow2Object

public static void RSRow2Object(ResultSet set,
                                Object obj)
                         throws SQLException
SQLException

jxUtil 0.6

Copyright © 2001,2002 Keve Müller, et al.; see LICENSE file for details.