de.mathema.pride
Class ResultSetAccess
java.lang.Object
de.mathema.pride.ResultSetAccess
public class ResultSetAccess
- extends java.lang.Object
This class holds meta information about access methods to
JDBC result sets. It is required for PriDE's generic way
of fetching record fields from an SQL query result.
By default, the class is initialized by its init()
method on the first call of #getAccessMethod(String)
or
#getIndexAccessMethod(String)
which in turn are called
by the constructors of class RecordDescriptor
.
However, you might be required to change the default
mappings according to your driver's abilities. E.g.
the default MySQL JDBC driver turned out not to support
making timestamps from ordinary date strings.
- Author:
- Jan Lessner
Method Summary |
protected static java.lang.reflect.Method |
findResultSetAccessMethod(java.lang.String methodName,
java.lang.Class<?> addressType)
|
static void |
init()
Initialize the class by the following default type mappings:
String -> getString
Enum -> getString
java.util.Date -> getDate
java.sql.Date -> getDate
java.sql.Timestamp -> getTimestamp
Integer/int -> getInt
Float/float -> getFloat
Double/double -> getDouble
Boolean/boolean -> getBoolean
BigDecimal -> getBigDecimal
Long/long -> getLong
Short/short -> getShort
Byte/byte -> getByte
byte[] -> getBytes
Blob -> getBlob
Clob -> getClob
Map -> getObject, for Postgres only
Any array type -> getObject, for Postgres only
|
static void |
putMethod(java.lang.String methodName,
java.lang.Class valueType)
Adds a result set access method for a specified type |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REVISION_ID
public static final java.lang.String REVISION_ID
- See Also:
- Constant Field Values
ResultSetAccess
public ResultSetAccess()
putMethod
public static void putMethod(java.lang.String methodName,
java.lang.Class valueType)
throws java.lang.NoSuchMethodException
- Adds a result set access method for a specified type
- Parameters:
methodName
- Name of the access method to register. The
method is assumed to be applicable to the ResultSet class
for both access by name and access by index.valueType
- Name of the type to be accessed by the method
denoted by parameter methodName.
- Throws:
java.lang.NoSuchMethodException
- if the specified method is not
available for class java.sql.ResultSet
findResultSetAccessMethod
protected static java.lang.reflect.Method findResultSetAccessMethod(java.lang.String methodName,
java.lang.Class<?> addressType)
throws java.lang.NoSuchMethodException
- Throws:
java.lang.NoSuchMethodException
init
public static void init()
throws java.lang.NoSuchMethodException
- Initialize the class by the following default type mappings:
- String -> getString
- Enum -> getString
- java.util.Date -> getDate
- java.sql.Date -> getDate
- java.sql.Timestamp -> getTimestamp
- Integer/int -> getInt
- Float/float -> getFloat
- Double/double -> getDouble
- Boolean/boolean -> getBoolean
- BigDecimal -> getBigDecimal
- Long/long -> getLong
- Short/short -> getShort
- Byte/byte -> getByte
- byte[] -> getBytes
- Blob -> getBlob
- Clob -> getClob
- Map -> getObject, for Postgres only
- Any array type -> getObject, for Postgres only
- Throws:
java.lang.NoSuchMethodException