use of com.alibaba.druid.sql.parser.ParserException in project druid by alibaba.
the class MySqlSelectTest_plus_sub_comment method test_6.
public void test_6() throws Exception {
String sql = "select 1 ---++-- 1 ";
try {
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLSelectStatement stmt = (SQLSelectStatement) statementList.get(0);
fail();
} catch (Exception e) {
assertTrue(e instanceof ParserException);
}
}
use of com.alibaba.druid.sql.parser.ParserException in project druid by alibaba.
the class MySqlSelectTest_plus_sub_comment method test_16.
public void test_16() throws Exception {
String sql = "select max(id) --+-- min(id) from test_tablesl";
try {
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLSelectStatement stmt = (SQLSelectStatement) statementList.get(0);
fail();
} catch (Exception e) {
assertTrue(e instanceof ParserException);
}
}
use of com.alibaba.druid.sql.parser.ParserException in project druid by alibaba.
the class MySqlSelectTest_plus_sub_comment method test_13.
public void test_13() throws Exception {
String sql = "select max(id) --- min(id) from test_tablesl";
try {
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLSelectStatement stmt = (SQLSelectStatement) statementList.get(0);
fail();
} catch (Exception e) {
assertTrue(e instanceof ParserException);
}
}
use of com.alibaba.druid.sql.parser.ParserException in project druid by alibaba.
the class OdpsLexerTest method test_error_0.
public void test_error_0() throws Exception {
String str = "1 `aaa\n${PN}_events";
OdpsLexer lexer = new OdpsLexer(str);
lexer.nextToken();
assertEquals(Token.LITERAL_INT, lexer.token());
int pos = lexer.pos();
try {
lexer.nextToken();
} catch (ParserException error) {
lexer.skipToNextLineOrParameter(pos);
lexer.nextToken();
}
assertEquals(Token.IDENTIFIER, lexer.token());
assertEquals("${PN}_events", lexer.stringVal());
}
use of com.alibaba.druid.sql.parser.ParserException in project druid by alibaba.
the class AntlrExamplesTest method test_for_antlr_examples.
public void test_for_antlr_examples() throws Exception {
String path = "bvt/parser/antlr_grammers_v4_plsql/examples/";
URL resource = Thread.currentThread().getContextClassLoader().getResource(path);
File dir = new File(resource.getFile());
for (File file : dir.listFiles()) {
System.out.println(file);
String sql = FileUtils.readFileToString(file);
try {
SQLUtils.parseStatements(sql, JdbcConstants.ORACLE);
} catch (ParserException ex) {
System.out.println(sql);
throw ex;
}
}
}
Aggregations