improved sql parser.

This commit is contained in:
wenshao
2017-06-21 12:49:49 +08:00
parent 17c22cf84a
commit a679837026
13 changed files with 952 additions and 7 deletions
@@ -29,6 +29,8 @@ import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.HashSet;
import java.util.Set;
public class MySqlUtils {
static Class<?> utilClass;
@@ -104,4 +106,24 @@ public class MySqlUtils {
}
return null;
}
private static Set<String> keywords;
public static boolean isKeyword(String name) {
if (name == null) {
return false;
}
String name_lower = name.toLowerCase();
Set<String> words = keywords;
if (words == null) {
words = new HashSet<String>();
Utils.loadFromFile("META-INF/druid/parser/mysql/keywords", words);
keywords = words;
}
return words.contains(name_lower);
}
}