protected Map<String, ParamInfo> prmsh = new TreeMap<String, ParamInfo>();
public synchronized void prepare(String alias, String query)
throws SysException {
if (this.alias != null)
throw new SysException("The statement is not closed");
if (alias == null)
throw new SysException("The database's alias can't be null");
int i = 0;
int l = query.length();
StringBuffer sql = new StringBuffer();
int c = 0;
int len;
while (i < l) {
int j = query.indexOf(idf, i);
if (j >= 0) {
sql.append(query.substring(i, j));
i = j + idf.length();
len = Strings.chooseIdentifier(query, i);
if (len > 0) {
i += len;
String name = query.substring(i - len, i);
ParamInfo pi = prmsh.get(name);
if (pi == null) {
pi = new StatementNew.ParamInfo();
pi.NAME = name;
prmsh.put(name, pi);
}
c++;
pi.links.add(c);
prmsi.add(pi);
sql.append('?');
} else {
sql.append(idf);
}
} else {
sql.append(query.substring(i));
i = l;
}
}
this.sql = sql.toString();
Connection con = null;
try {
con = Manager.getConnection(alias);
tp = Manager.getTypes(con);
PreparedStatement st = null;
try {
st = con.prepareStatement(this.sql);
try {
prms = tp.getParams(st);
} catch (Throwable ex) {
prms = new RsParam[prmsi.size()];
}
} catch (SQLException ex) {
throw new SysException(ex);
} finally {
if (st != null)
try {
st.close();
} catch (SQLException e) {