use of io.shardingjdbc.core.parsing.parser.sql.SQLStatement in project sharding-jdbc by shardingjdbc.
the class SQLParsingEngine method parse.
/**
* Parse SQL.
*
* @return parsed SQL statement
*/
public SQLStatement parse() {
SQLStatement cachedSQLStatement = ParsingResultCache.getInstance().getSQLStatement(sql);
if (null != cachedSQLStatement) {
return cachedSQLStatement;
}
LexerEngine lexerEngine = LexerEngineFactory.newInstance(dbType, sql);
lexerEngine.nextToken();
return SQLParserFactory.newInstance(dbType, lexerEngine.getCurrentToken().getType(), shardingRule, lexerEngine).parse();
}
use of io.shardingjdbc.core.parsing.parser.sql.SQLStatement in project sharding-jdbc by shardingjdbc.
the class MergeEngineFactoryTest method assertNewInstanceWithDALStatement.
@Test
public void assertNewInstanceWithDALStatement() throws SQLException {
SQLStatement dalStatement = new DALStatement();
assertThat(MergeEngineFactory.newInstance(null, queryResults, dalStatement), instanceOf(DALMergeEngine.class));
}
use of io.shardingjdbc.core.parsing.parser.sql.SQLStatement in project sharding-jdbc by shardingjdbc.
the class MergeEngineFactoryTest method assertNewInstanceWithSelectStatement.
@Test
public void assertNewInstanceWithSelectStatement() throws SQLException {
SQLStatement selectStatement = new SelectStatement();
assertThat(MergeEngineFactory.newInstance(null, queryResults, selectStatement), instanceOf(DQLMergeEngine.class));
}
use of io.shardingjdbc.core.parsing.parser.sql.SQLStatement in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method execute.
@Override
public boolean execute(final String sql, final String[] columnNames) throws SQLException {
boolean result = false;
SQLStatement sqlStatement = new SQLJudgeEngine(sql).judge();
for (Connection each : connection.getConnections(sqlStatement.getType())) {
Statement statement = each.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
routedStatements.add(statement);
result = statement.execute(sql, columnNames);
}
return result;
}
use of io.shardingjdbc.core.parsing.parser.sql.SQLStatement in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method execute.
@Override
public boolean execute(final String sql) throws SQLException {
boolean result = false;
SQLStatement sqlStatement = new SQLJudgeEngine(sql).judge();
for (Connection each : connection.getConnections(sqlStatement.getType())) {
Statement statement = each.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
routedStatements.add(statement);
result = statement.execute(sql);
}
return result;
}
Aggregations