/// @throws AcquireError If connection could not be retrieved
/// @throws SQLError If SQL error occured
public static final Any query(Context context, String ckey, String query, Any[] parameters)
{
PooledConnection connImpl = acquireConnection(context, ckey, true, false);
if (connImpl == null) {
return Any.NULL;
}
Connection conn = (Connection)connImpl.getConnection();
try {
Statement stmt = conn.createStatement();
stmt.setEscapeProcessing(false);
String queryString;
if (parameters.length == 0) {
queryString = query;
} else {
queryString = SQLUtil.buildQueryString(query, parameters, 0);
}
Any returnValue;
if (stmt.execute(queryString)) {
returnValue = new AnyResultSet(stmt.getResultSet(), stmt);
} else {
returnValue = Any.create(stmt.getUpdateCount());
stmt.close();
}
return returnValue;
} catch (SQLException e) {
try {
conn.close();
} catch (Exception e2) {
}
throw context.exception(e);
} finally {
connImpl.release();
}
}