mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user