This is the situation
There is a great need for abstraction over JDBC in jOOQ . I want the jOOQ client code not to know that some data is retrieved from a simple ResultSet, some data is retrieved from SQLInput (for UDT) or from CallableStatements (for stored procedures / functions). Therefore, I want to add an abstraction over these JDBC types:
java.sql.ResultSet
java.sql.CallableStatement
java.sql.SQLInput
java.sql.SQLOutput
Now they all work pretty much the same. Usually they have a method getand setfor each data type in java.sql.Types. For example, they come with methods such as
BigDecimal getBigDecimal(int index);
int getInt(int index);
And everyone has methods like
boolean wasNull();
Problem
, JDBC , , JDBC-, , ( ):
BigDecimal result = null;
if (source instanceof ResultSet) {
result = ((ResultSet) source).getBigDecimal(index);
}
else if (source instanceof CallableStatement) {
result = ((CallableStatement) source).getBigDecimal(index);
}
else if (source instanceof SQLInput) {
result = ((SQLInput) source).readBigDecimal();
}
return result == null ? null : result.toBigInteger();
, ResultSet, CallableStatement, SQLInput.
?