public static QueryImpl __execute(PageContext pc, SQL sql, int maxrows, int fetchsize, int timeout,Stopwatch stopwatch,Set<String> tables, boolean doSimpleTypes) throws PageException {
ArrayList<String> usedTables=new ArrayList<String>();
synchronized(lock) {
QueryImpl nqr=null;
ConfigImpl config = (ConfigImpl)pc.getConfig();
DatasourceConnectionPool pool = config.getDatasourceConnectionPool();
DatasourceConnection dc=pool.getDatasourceConnection(pc,config.getDataSource(QOQ_DATASOURCE_NAME),"sa","");
Connection conn = dc.getConnection();
try {
DBUtil.setAutoCommitEL(conn,false);
//sql.setSQLString(HSQLUtil.sqlToZQL(sql.getSQLString(),false));
try {
Iterator<String> it = tables.iterator();
//int len=tables.size();
while(it.hasNext()) {
String tableName=it.next().toString();//tables.get(i).toString();
String modTableName=tableName.replace('.','_');
String modSql=StringUtil.replace(sql.getSQLString(),tableName,modTableName,false);
sql.setSQLString(modSql);
addTable(conn,pc,modTableName,Caster.toQuery(pc.getVariable(tableName)),doSimpleTypes,usedTables);
}
DBUtil.setReadOnlyEL(conn,true);
try {
nqr =new QueryImpl(pc,dc,sql,maxrows,fetchsize,timeout,"query",null,false,false);
}
finally {
DBUtil.setReadOnlyEL(conn,false);
DBUtil.commitEL(conn);
DBUtil.setAutoCommitEL(conn,true);
}
}
catch (SQLException e) {
DatabaseException de = new DatabaseException("there is a problem to execute sql statement on query",null,sql,null);
de.setDetail(e.getMessage());
throw de;
}
}
finally {
removeAll(conn,usedTables);
DBUtil.setAutoCommitEL(conn,true);
pool.releaseDatasourceConnection(dc);
//manager.releaseConnection(dc);
}
nqr.setExecutionTime(stopwatch.time());
return nqr;
}
}