Package org.castor.jdo.engine
Class SQLTypeInfos
java.lang.Object
org.castor.jdo.engine.SQLTypeInfos
Utility class to translate SQL type by integer value or name into corresponding
Java type.
- Since:
- 1.0
- Version:
- $Revision: 8654 $ $Date: 2006-04-08 08:58:10 -0600 (Sat, 08 Apr 2006) $
- Author:
- Ralf Joachim
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Get value from given ResultSet at given index with given SQL type.static int
javaType2sqlTypeNum
(Class<?> javaType) Returns the SQL type from the specified Java type.static void
setValue
(PreparedStatement stmt, int index, Object value, int sqlType) Set given value on given PreparedStatement at given index with given SQL type.static Class<?>
sqlTypeName2javaType
(String sqlTypeName) Returns the Java type for the given SQL type name.static Class<?>
sqlTypeNum2javaType
(int sqlTypeNum) Returns the Java type for the given SQL type.static String
sqlTypeNum2sqlTypeName
(int sqlTypeNum) Returns the SQL type name for the given SQL type number.
-
Method Details
-
sqlTypeNum2javaType
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.
-
sqlTypeNum2sqlTypeName
Returns the SQL type name for the given SQL type number.- Parameters:
sqlTypeNum
- SQL type name (see JDBC API)- Returns:
- The SQL type name.
- Throws:
MappingException
- The SQL type is not recognized.
-
sqlTypeName2javaType
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
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
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:
SQLException
- If a database access error occurs.
-
setValue
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.
-