Search in sources :

Example 1 with SQLJudgeEngine

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 String[] columnNames) 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, columnNames);
    }
    return result;
}
Also used : SQLJudgeEngine(io.shardingjdbc.core.parsing.SQLJudgeEngine) Statement(java.sql.Statement) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement) Connection(java.sql.Connection) MasterSlaveConnection(io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement)

Example 2 with SQLJudgeEngine

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[] columnIndexes) 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, columnIndexes);
    }
    return result;
}
Also used : SQLJudgeEngine(io.shardingjdbc.core.parsing.SQLJudgeEngine) Statement(java.sql.Statement) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement) Connection(java.sql.Connection) MasterSlaveConnection(io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement)

Example 3 with SQLJudgeEngine

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 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;
}
Also used : SQLJudgeEngine(io.shardingjdbc.core.parsing.SQLJudgeEngine) Statement(java.sql.Statement) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement) Connection(java.sql.Connection) MasterSlaveConnection(io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement)

Example 4 with SQLJudgeEngine

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) 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;
}
Also used : SQLJudgeEngine(io.shardingjdbc.core.parsing.SQLJudgeEngine) Statement(java.sql.Statement) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement) Connection(java.sql.Connection) MasterSlaveConnection(io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement)

Example 5 with SQLJudgeEngine

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 autoGeneratedKeys) 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, autoGeneratedKeys);
    }
    return result;
}
Also used : SQLJudgeEngine(io.shardingjdbc.core.parsing.SQLJudgeEngine) Statement(java.sql.Statement) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement) Connection(java.sql.Connection) MasterSlaveConnection(io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection) SQLStatement(io.shardingjdbc.core.parsing.parser.sql.SQLStatement)

Aggregations

MasterSlaveConnection (io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection)9 SQLJudgeEngine (io.shardingjdbc.core.parsing.SQLJudgeEngine)9 SQLStatement (io.shardingjdbc.core.parsing.parser.sql.SQLStatement)9 Connection (java.sql.Connection)9 Statement (java.sql.Statement)9