private Object executeSql(String sqlString,
PreparedStatementParameter[] parameters,
String resourceName, boolean isSelect) throws
BaseException {
if (sqlString == null) {
throw new PersistentStorageException(getClass().getName(),
"SQL is null");
}
if (resourceName == null) {
throw new PersistentStorageException(getClass().getName(),
"Resource name is null");
}
Connection con = getSqlConnection(resourceName);
if (con == null) {
throw new PersistentStorageException(getClass().getName(),
"Connection is not available: " + resourceName);
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = con.prepareStatement(sqlString);
if (parameters != null) {
for (int i = 0; i < parameters.length; i++) {
int type = parameters[i].getType();
Object value = parameters[i].getValue();
if (value != null) {
pstmt.setObject(i + 1, value);
}
else {
pstmt.setNull(i + 1, parameters[i].getType());
}
}
}
if (isSelect) {
rs = pstmt.executeQuery();
ResultSetMetaData data = rs.getMetaData();
int count = data.getColumnCount();
Vector v = new Vector();
while (rs.next()) {
PreparedStatementResult result = new
PreparedStatementResult();
for (int i = 1; i < count + 1; i++) {
Object value = rs.getObject(i);
result.add(data.getColumnName(i), value);
}
v.add(result);
}
return v;
}
return new Integer(pstmt.executeUpdate());
}
catch (SQLException e) {
throw new PersistentStorageException(getClass().getName(),
"Exception executing query", e);
}
finally {
try {
if (rs != null) {