try {
String stName = st.getName();
autoFill(udc, inputs);
JdbcStatement jstat = st;
String originalSql = st.getOriginalJdbcStatementString();
if(checkPagination(inputs)) {
String pagedSql = dba.preparePaginationSql(originalSql, inputs, outputFilters);
jstat = SqlExpressUtil.createJdbcStatementDirect(pagedSql);
}
String executableSql = jstat.getExecutableJdbcStatementString();
executableSql = autoReplace(executableSql, inputs);
log.debug("execute - parsed expecutable sql: " + executableSql);
log.debug("execute - parsed inputs: " + inputs);
log.debug("execute - outputFilters: " + outputFilters);
boolean supportsGetGeneratedKeys = supportsGetGeneratedKeys();
if (supportsGetGeneratedKeys && !jstat.isSelectStatement()) {
pstmt = connection.prepareStatement(executableSql, Statement.RETURN_GENERATED_KEYS);
}
else {
pstmt = connection.prepareStatement(executableSql);
}
// check if need to load parameter properties
// if (supportParameterMetaData()) {
// if (!jstat.hasLoadedParameterMetaData()) {
// //get parameter meta data if it has not been loaded
// ParameterMetaData pmd = pstmt.getParameterMetaData();
// ParameterMetaDataLoader pmdl = new ParameterMetaDataLoader(pmd, jstat);
// pmdl.loadParameterMetaData();
// }
// }
// else {
if (!jstat.hasLoadedParameterProperties()) {
synchronized(jstat) {
if (!jstat.hasLoadedParameterProperties()) {
JdbcStatementParser parser = new JdbcStatementParser(udc, jstat);
parser.parse();
}
}
}
// }
Collection<Parameter> parameters = jstat.getParameters();
log.debug("execute - parameters: " + parameters);
Iterator<Parameter> pit = parameters.iterator();
while(pit.hasNext()) {
Parameter p = pit.next();
String key = p.getName();
if (!inputs.containsKey(key)) {
throw new Exception("There " +
"must be a key/value pair corresponding to key named " + key +
" in input parameters: " + inputs.keySet());
}
if (Parameter.MODE_IN.equals(p.getMode())) {
Object obj = inputs.get(key);
if (obj == null ||
"".equals(obj.toString().trim()) &&
p.getSqlDataType() != Types.CHAR &&
p.getSqlDataType() != Types.VARCHAR &&
p.getSqlDataType() != Types.LONGVARCHAR) {
setNull(pstmt, p.getIndex(), p.getSqlDataType());
}
else {
if(!dba.vendorSpecificSetObject(pstmt, obj, p, inputs)) {
if (Parameter.UNKNOWN_SQL_DATA_TYPE != p.getSqlDataType()) {
setObject(pstmt, obj, p);
}
else {
//It is up to JDBC driver's PreparedStatement implementation
//class to deal with. Usually the class will make a decision
//on which setXXX(Type) method to call based on the java
//class type of the obj instance.
pstmt.setObject(p.getIndex(), obj);
}
}
}
}
}
if (jstat.isSelectStatement()) {
rs = pstmt.executeQuery();
// handle out cursors or other outputs if there is any
if (rs != null) {
if (outputFilters == null || outputFilters.size() == 0) {