use of io.shardingjdbc.core.parsing.SQLJudgeEngine in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method executeUpdate.
@Override
public int executeUpdate(final String sql, final int[] columnIndexes) throws SQLException {
int result = 0;
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.executeUpdate(sql, columnIndexes);
}
return result;
}
use of io.shardingjdbc.core.parsing.SQLJudgeEngine in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method executeQuery.
@Override
public ResultSet executeQuery(final String sql) throws SQLException {
SQLStatement sqlStatement = new SQLJudgeEngine(sql).judge();
Collection<Connection> connections = connection.getConnections(sqlStatement.getType());
Preconditions.checkState(1 == connections.size(), "Cannot support executeQuery for DDL");
Statement statement = connections.iterator().next().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
routedStatements.add(statement);
return statement.executeQuery(sql);
}
use of io.shardingjdbc.core.parsing.SQLJudgeEngine in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method executeUpdate.
@Override
public int executeUpdate(final String sql) throws SQLException {
int result = 0;
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.executeUpdate(sql);
}
return result;
}
use of io.shardingjdbc.core.parsing.SQLJudgeEngine in project sharding-jdbc by shardingjdbc.
the class MasterSlaveStatement method execute.
@Override
public boolean execute(final String sql, final int autoGeneratedKeys) 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, autoGeneratedKeys);
}
return result;
}
Aggregations