Java Code Examples for java.sql.Statement#setEscapeProcessing()

The following examples show how to use java.sql.Statement#setEscapeProcessing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractStatementAdapter.java    From sharding-jdbc-1.5.1 with Apache License 2.0 5 votes vote down vote up
@Override
public final void setEscapeProcessing(final boolean enable) throws SQLException {
    if (getRoutedStatements().isEmpty()) {
        recordMethodInvocation(recordTargetClass, "setEscapeProcessing", new Class[] {boolean.class}, new Object[] {enable});
        return;
    }
    for (Statement each : getRoutedStatements()) {
        each.setEscapeProcessing(enable);
    }
}
 
Example 2
Source File: StatementAdapterTest.java    From sharding-jdbc-1.5.1 with Apache License 2.0 5 votes vote down vote up
@Test
public void assertSetEscapeProcessing() throws SQLException {
    for (Statement each : statements.values()) {
        each.setEscapeProcessing(true);
        each.executeQuery(sql);
        each.setEscapeProcessing(false);
    }
}
 
Example 3
Source File: BrokeredStatement.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException {
	if (cursorName != null)
		newStatement.setCursorName(cursorName);
	if (escapeProcessing != null)
		newStatement.setEscapeProcessing(escapeProcessing.booleanValue());

	newStatement.setFetchDirection(oldStatement.getFetchDirection());
	newStatement.setFetchSize(oldStatement.getFetchSize());
	newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize());
	newStatement.setMaxRows(oldStatement.getMaxRows());
	newStatement.setQueryTimeout(oldStatement.getQueryTimeout());
}
 
Example 4
Source File: StatementAdapterTest.java    From shardingsphere with Apache License 2.0 5 votes vote down vote up
@Test
public void assertSetEscapeProcessing() throws SQLException {
    for (Statement each : statements.values()) {
        each.setEscapeProcessing(true);
        each.executeQuery(sql);
        each.setEscapeProcessing(false);
    }
}
 
Example 5
Source File: SqlServerStream.java    From dkpro-jwpl with Apache License 2.0 5 votes vote down vote up
public void writeStatement(CharSequence sql) throws IOException {
	Statement statement;
	try {
		statement = connection.createStatement();
		statement.setEscapeProcessing(false);
		statement.execute(sql.toString());
	} catch (SQLException e) {
		throw new IOException(e.toString());
	}
}
 
Example 6
Source File: BrokeredStatement.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException {
	if (cursorName != null)
		newStatement.setCursorName(cursorName);
	if (escapeProcessing != null)
		newStatement.setEscapeProcessing(escapeProcessing.booleanValue());

	newStatement.setFetchDirection(oldStatement.getFetchDirection());
	newStatement.setFetchSize(oldStatement.getFetchSize());
	newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize());
	newStatement.setMaxRows(oldStatement.getMaxRows());
	newStatement.setQueryTimeout(oldStatement.getQueryTimeout());
}
 
Example 7
Source File: BrokeredStatement.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException {
	if (cursorName != null)
		newStatement.setCursorName(cursorName);
	if (escapeProcessing != null)
		newStatement.setEscapeProcessing(escapeProcessing);

	newStatement.setFetchDirection(oldStatement.getFetchDirection());
	newStatement.setFetchSize(oldStatement.getFetchSize());
	newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize());
	newStatement.setMaxRows(oldStatement.getMaxRows());
	newStatement.setQueryTimeout(oldStatement.getQueryTimeout());
}
 
Example 8
Source File: SWStatementTest.java    From skywalking with Apache License 2.0 4 votes vote down vote up
@Test
public void testPreparedStatementConfig() throws SQLException {
    Statement statement = swConnection.createStatement();
    statement.cancel();
    statement.getUpdateCount();
    statement.setFetchDirection(1);
    statement.getFetchDirection();
    statement.getResultSetConcurrency();
    statement.getResultSetType();
    statement.isClosed();
    statement.setPoolable(false);
    statement.isPoolable();
    statement.getWarnings();
    statement.clearWarnings();
    statement.setCursorName("test");
    statement.setMaxFieldSize(11);
    statement.getMaxFieldSize();
    statement.setMaxRows(10);
    statement.getMaxRows();
    statement.setEscapeProcessing(true);
    statement.setFetchSize(1);
    statement.getFetchSize();
    statement.setQueryTimeout(1);
    statement.getQueryTimeout();
    Connection connection = statement.getConnection();

    statement.execute("SELECT * FROM test");
    statement.getMoreResults();
    statement.getMoreResults(1);
    statement.getResultSetHoldability();
    statement.getResultSet();

    statement.close();
    verify(mysqlStatement).getUpdateCount();
    verify(mysqlStatement).getMoreResults();
    verify(mysqlStatement).setFetchDirection(anyInt());
    verify(mysqlStatement).getFetchDirection();
    verify(mysqlStatement).getResultSetType();
    verify(mysqlStatement).isClosed();
    verify(mysqlStatement).setPoolable(anyBoolean());
    verify(mysqlStatement).getWarnings();
    verify(mysqlStatement).clearWarnings();
    verify(mysqlStatement).setCursorName(anyString());
    verify(mysqlStatement).setMaxFieldSize(anyInt());
    verify(mysqlStatement).getMaxFieldSize();
    verify(mysqlStatement).setMaxRows(anyInt());
    verify(mysqlStatement).getMaxRows();
    verify(mysqlStatement).setEscapeProcessing(anyBoolean());
    verify(mysqlStatement).getResultSetConcurrency();
    verify(mysqlStatement).getResultSetConcurrency();
    verify(mysqlStatement).getResultSetType();
    verify(mysqlStatement).getMoreResults(anyInt());
    verify(mysqlStatement).setFetchSize(anyInt());
    verify(mysqlStatement).getFetchSize();
    verify(mysqlStatement).getQueryTimeout();
    verify(mysqlStatement).setQueryTimeout(anyInt());
    verify(mysqlStatement).getResultSet();
    assertThat(connection, CoreMatchers.<Connection>is(swConnection));

    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/Statement/execute", "SELECT * FROM test");
}