站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 server API Documentation 英文版文档

JDBCUtil (JBoss Server API) - JBoss 4.0.1 sp1 server API Documentation 英文版文档


org.jboss.ejb.plugins.cmp.jdbc
Class JDBCUtil

java.lang.Object
  extended byorg.jboss.ejb.plugins.cmp.jdbc.JDBCUtil

public final class JDBCUtil
extends Object

JDBCUtil takes care of some of the more anoying JDBC tasks. It hanles safe closing of jdbc resources, setting statement parameters and loading query results.

Version:
$Revision: 1.25 $
Author:
Dain Sundstrom, Alex Loubyansky, Steve Coy

Constructor Summary
JDBCUtil()
           
 
Method Summary
static Object coerceToSQLType(int jdbcType, Object value)
          Coerces the input value into the correct type for the specified jdbcType.
static byte[] convertObjectToByteArray(Object value)
          Coverts the value into a byte array.
static Object convertToObject(byte[] input)
          Coverts the input into an object.
static Object convertToObject(InputStream input)
          Coverts the input into an object.
static byte[] getByteArray(InputStream input)
          Read the entire input stream provided and return its content as a byte array.
static String getJDBCTypeName(int jdbcType)
          Gets the JDBC type name corresponding to the given type code.
static String getLongString(ResultSet rs, int index)
          Get the indicated result set parameter as a character stream and return it's entire content as a String.
static Object getParameter(org.jboss.logging.Logger log, CallableStatement cs, int index, int jdbcType, Class destination)
          Used for all retrieval of parameters from CallableStatements.
static JDBCParameterSetter getParameterSetter(int jdbcType, Class javaType)
           
static JDBCResultSetReader getResultReaderByType(Class destination)
           
static JDBCResultSetReader getResultSetReader(int jdbcType, Class destination)
           
static void safeClose(Connection con)
           
static void safeClose(InputStream in)
           
static void safeClose(OutputStream out)
           
static void safeClose(Reader reader)
           
static void safeClose(ResultSet rs)
           
static void safeClose(Statement statement)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCUtil

public JDBCUtil()
Method Detail

safeClose

public static void safeClose(Connection con)

safeClose

public static void safeClose(ResultSet rs)

safeClose

public static void safeClose(Statement statement)

safeClose

public static void safeClose(InputStream in)

safeClose

public static void safeClose(OutputStream out)

safeClose

public static void safeClose(Reader reader)

coerceToSQLType

public static Object coerceToSQLType(int jdbcType,
                                     Object value)
Coerces the input value into the correct type for the specified jdbcType.

Parameters:
jdbcType - the jdbc type to which the value will be assigned
value - the value to coerce
Returns:
the corrected object

convertObjectToByteArray

public static byte[] convertObjectToByteArray(Object value)
                                       throws SQLException
Coverts the value into a byte array.

Parameters:
value - the value to convert into a byte array
Returns:
the byte representation of the value
Throws:
SQLException - if a problem occures in the conversion

convertToObject

public static Object convertToObject(byte[] input)
                              throws SQLException
Coverts the input into an object.

Parameters:
input - the bytes to convert
Returns:
the object repsentation of the input stream
Throws:
SQLException - if a problem occures in the conversion

convertToObject

public static Object convertToObject(InputStream input)
                              throws SQLException
Coverts the input into an object.

Parameters:
input - the bytes to convert
Returns:
the object repsentation of the input stream
Throws:
SQLException - if a problem occures in the conversion

getLongString

public static String getLongString(ResultSet rs,
                                   int index)
                            throws SQLException
Get the indicated result set parameter as a character stream and return it's entire content as a String.

Parameters:
rs - the ResultSet from which a result is being retrieved.
index - index of the result column.
Returns:
a String containing the content of the result column
Throws:
SQLException

getByteArray

public static byte[] getByteArray(InputStream input)
                           throws SQLException
Read the entire input stream provided and return its content as a byte array.

Parameters:
input - the InputStream from which a result is being retrieved.
Returns:
a byte array containing the content of the input stream
Throws:
SQLException

getResultSetReader

public static JDBCResultSetReader getResultSetReader(int jdbcType,
                                                     Class destination)

getResultReaderByType

public static JDBCResultSetReader getResultReaderByType(Class destination)

getParameterSetter

public static JDBCParameterSetter getParameterSetter(int jdbcType,
                                                     Class javaType)

getJDBCTypeName

public static String getJDBCTypeName(int jdbcType)
Gets the JDBC type name corresponding to the given type code. Only used in debug log messages.

Parameters:
jdbcType - the integer JDBC type code.
Returns:
the JDBC type name.
See Also:
Types

getParameter

public static Object getParameter(org.jboss.logging.Logger log,
                                  CallableStatement cs,
                                  int index,
                                  int jdbcType,
                                  Class destination)
                           throws SQLException
Used for all retrieval of parameters from CallableStatements. Implements tracing, and allows some tweaking of returned types.

Parameters:
log - where to log to
cs - the CallableStatement from which an out parameter is being retrieved
index - index of the result column.
jdbcType - a Types constant used to determine the most appropriate way to extract the data from rs.
destination - The class of the variable this is going into
Returns:
the value
Throws:
SQLException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.