org.apache.cocoon.util
Class JDBCTypeConversions

java.lang.Object
  extended byorg.apache.cocoon.util.JDBCTypeConversions

public class JDBCTypeConversions
extends Object

Provide some utility methods to read from JDBC result sets or store them to JDBC statements. Largely copied from org.apache.cocoon.acting.AbstractDatabaseAction.

The following table lists all available column type names together with the JDBC methods used to get or set a column with that type. In some cases the returned type differs from the type returned by the getXXX method. To set a column, a number of conversions are automatically used. For details, please see the actual code.

type getXXX returns setXXX
clob Clob String Clob
ascii Clob String asciStream
big-decimalBigDecimal BigDecimal
binary BinaryStream
blob Blob
boolean Boolean Boolean Boolean
byte Byte Byte Byte
string String String
date Date Date
double Double Double Double
float Float Float Float
int Int Integer Int
long Long Long Long
short Short Short
time Time Time
time-stamp Timestamp Timestamp
array Array Array
row Object Struct Object
object Object Object

Version:
$Id: JDBCTypeConversions.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
static Map typeConstants
           
 
Constructor Summary
JDBCTypeConversions()
           
 
Method Summary
static Object convert(Object value, String jType)
          Converts an object to a JDBC type.
static Object getColumn(ResultSet set, Configuration column)
          Get the Statement column so that the results are mapped correctly.
static void setColumn(PreparedStatement statement, int position, Object value, Integer typeObject)
          Set the Statement column so that the results are mapped correctly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typeConstants

public static final Map typeConstants
Constructor Detail

JDBCTypeConversions

public JDBCTypeConversions()
Method Detail

convert

public static Object convert(Object value,
                             String jType)
Converts an object to a JDBC type. This has just been started and does not do much at the moment.


getColumn

public static Object getColumn(ResultSet set,
                               Configuration column)
                        throws Exception
Get the Statement column so that the results are mapped correctly. (this has been copied from AbstractDatabaseAction and modified slightly)

Throws:
Exception

setColumn

public static void setColumn(PreparedStatement statement,
                             int position,
                             Object value,
                             Integer typeObject)
                      throws Exception
Set the Statement column so that the results are mapped correctly.

Parameters:
statement - the prepared statement
position - the position of the column
value - the value of the column
Throws:
Exception


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.