public class SQLUtil {
public static List<String> tokenize(String schema) {
List<String> ret=new ArrayList<String>();
if (schema!=null) {
QueryTokenizer tokenizer=new QueryTokenizer(";","--",true);
QueryTokenizer extraTokenizer=null;
if (DbConnectionFactory.isMsSql()) {
//";","--",true
IQueryTokenizerPreferenceBean prefs = new MSSQLPreferenceBean();
//prefs.setStatementSeparator("GO");
extraTokenizer=new MSSQLQueryTokenizer(prefs);
}else if(DbConnectionFactory.isOracle()){
IQueryTokenizerPreferenceBean prefs = new OraclePreferenceBean();
tokenizer=new OracleQueryTokenizer(prefs);
}else if(DbConnectionFactory.isMySql()){
IQueryTokenizerPreferenceBean prefs = new BaseQueryTokenizerPreferenceBean();
prefs.setProcedureSeparator("#");
tokenizer=new MysqlQueryTokenizer(prefs);
}
tokenizer.setScriptToTokenize(schema.toString());
while (tokenizer.hasQuery() )
{
String querySql = tokenizer.nextQuery();
if (querySql != null)
{
if (extraTokenizer !=null) {
extraTokenizer.setScriptToTokenize(querySql);
if (extraTokenizer.hasQuery()) {
while (extraTokenizer.hasQuery()) {
String innerSql = extraTokenizer.nextQuery();
if (innerSql!=null) {
ret.add(innerSql);
}
}