org.castor.jdo.engine
Class SQLTypeInfos

java.lang.Object
  extended by org.castor.jdo.engine.SQLTypeInfos

public final class SQLTypeInfos
extends java.lang.Object

Utility class to translate SQL type by integer value or name into corresponding Java type.

Since:
1.0
Version:
$Revision: 8034 $ $Date: 2006-04-08 08:58:10 -0600 (Sat, 08 Apr 2006) $
Author:
Ralf Joachim

Method Summary
static java.lang.Object getValue(java.sql.ResultSet rs, int index, int sqlType)
          Get value from given ResultSet at given index with given SQL type.
static int javaType2sqlTypeNum(java.lang.Class javaType)
          Returns the SQL type from the specified Java type.
static void setValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value, int sqlType)
          Set given value on given PreparedStatement at given index with given SQL type.
static java.lang.Class sqlTypeName2javaType(java.lang.String sqlTypeName)
          Returns the Java type for the given SQL type name.
static java.lang.Class sqlTypeNum2javaType(int sqlTypeNum)
          Returns the Java type for the given SQL type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sqlTypeNum2javaType

public static java.lang.Class sqlTypeNum2javaType(int sqlTypeNum)
                                           throws MappingException
Returns the Java type for the given SQL type.

Parameters:
sqlTypeNum - SQL type name (see JDBC API)
Returns:
The suitable Java type
Throws:
MappingException - The SQL type is not recognized.

sqlTypeName2javaType

public static java.lang.Class sqlTypeName2javaType(java.lang.String sqlTypeName)
                                            throws MappingException
Returns the Java type for the given SQL type name.

Parameters:
sqlTypeName - SQL type name (e.g. numeric).
Returns:
The suitable Java type.
Throws:
MappingException - The SQL type is not recognized.

javaType2sqlTypeNum

public static int javaType2sqlTypeNum(java.lang.Class javaType)
Returns the SQL type from the specified Java type. Returns OTHER if the Java type has no suitable SQL type mapping.

Parameters:
javaType - The Java class of the SQL type.
Returns:
SQL type from the specified Java type.

getValue

public static java.lang.Object getValue(java.sql.ResultSet rs,
                                        int index,
                                        int sqlType)
                                 throws java.sql.SQLException
Get value from given ResultSet at given index with given SQL type.

Parameters:
rs - The ResultSet to get the value from.
index - The index of the value in the ResultSet.
sqlType - The SQL type of the value.
Returns:
The value.
Throws:
java.sql.SQLException - If a database access error occurs.

setValue

public static void setValue(java.sql.PreparedStatement stmt,
                            int index,
                            java.lang.Object value,
                            int sqlType)
Set given value on given PreparedStatement at given index with given SQL type.

Parameters:
stmt - The PreparedStatement to set value on.
index - The index of the value in the PreparedStatement.
value - The value to set.
sqlType - The SQL type of the value.


Copyright © 2011. All Rights Reserved.