// At this stage setting the UDS Data Type to Unknown. May need to create a mapping from the JDBC DataType to a DB_DT_ constant
cds.add(new DBColumnDesc(result.getInt("COLUMN_SIZE"), 0, result.getInt("DATA_TYPE"), result.getString("COLUMN_NAME"), result.getBoolean("NULLABLE"), result.getInt("DECIMAL_DIGITS")));
columnCount++;
}
if (columnCount == 0) {
UsageException errorVar = new UsageException("Cannot get column List from table: " + this.tableName + ", Table does not exist.");
ErrorMgr.addError(errorVar);
throw errorVar;
}
}
// TF:24/07/2008:Added support for columns descriptors on input data sets too
else if (statement != null && this.inputColMapping != null) { //PM:Aug 15, 2008:added null check on inputColMapping
// It's possibly a request for the column list off the input metadata
ParameterMetaData data = null;
try {
data = statement.getParameterMetaData();
}
catch (Exception e) {
// No dice, go with what we've got
}
int numCols = this.inputColMapping.size();
for (int i = 0; i < numCols; i++) {
String name = ":" + this.inputColMapping.get(i);
int type = Types.OTHER;
try {
if (data != null) {
type = data.getParameterType(i);
}
}
catch (Exception e) {}
int scale = 2;
try {
if (data != null) {
scale = data.getPrecision(i);
}
}
catch (Exception e) {};
cds.add(new DBColumnDesc(4, type, type, name, false, scale));
}
}
else if (resultSet != null) {
ResultSetMetaData data = this.resultSet.getMetaData();
int numCols = data.getColumnCount();
// AD:24/09/08 Column Count starts at 1 not 0
for (int i = 1; i <= numCols; i++) {
cds.add(new DBColumnDesc(data, i));
}
}
} catch (SQLException e) {
DataAccessException errorVar = new SQLErrorCodeSQLExceptionTranslator().translate("Cannot get column List from result set\n" + e.getMessage(), "", e );
ErrorMgr.addError(errorVar);
throw errorVar;
// PM:16/07/2008
} catch (NullPointerException e){
String msg = (e.getMessage() == null) ? e.getClass().getName() : e.getMessage();
UsageException errorVar = new UsageException("Cannot get column List from result set\n" + msg , e );
ErrorMgr.addError(errorVar);
throw errorVar;
}
return cds;
}