com.mysql.jdbc.PreparedStatement preparedStatement =
(com.mysql.jdbc.PreparedStatement)statement;
// key must be interned because we are using IdentityHashMap
String preparedSql = preparedStatement.getPreparedSql().intern();
// see if we have a parsed version of this query
Executor sQLExecutor = null;
synchronized(parsedSqlMap) {
sQLExecutor = parsedSqlMap.get(preparedSql);
}
// if no cached SQLExecutor, create it, which might take some time
if (sQLExecutor == null) {
sQLExecutor = createSQLExecutor(preparedSql);
if (sQLExecutor != null) {
// multiple thread might have created a SQLExecutor but it's ok
synchronized(parsedSqlMap) {
parsedSqlMap.put(preparedSql, sQLExecutor);
}
}
}
return sQLExecutor.execute(this, preparedStatement.getParameterBindings());
}
return null;
}