Java Code Examples for java.sql.CallableStatement#cancel()

The following examples show how to use java.sql.CallableStatement#cancel() . 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: SWCallableStatementTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecute() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");
    preparedStatement.setString(1, "a");
    boolean updateCount = preparedStatement.execute("UPDATE test SET  a = 1");
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).execute(anyString());
    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/execute", "UPDATE test SET  a = 1");
}
 
Example 2
Source File: SWCallableStatementTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteUpdate() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");
    preparedStatement.setString(1, "a");
    int updateCount = preparedStatement.executeUpdate();
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).executeUpdate();
    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET  a = ?");
}
 
Example 3
Source File: SWCallableStatementTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateSql() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");

    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1");
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).executeUpdate(anyString());
    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}
 
Example 4
Source File: SWCallableStatementTest.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateWithAutoGeneratedKey() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");

    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1", 1);
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}
 
Example 5
Source File: SWCallableStatementTest.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateWithIntColumnIndexes() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");

    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1", new int[] {1});
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}
 
Example 6
Source File: SWCallableStatementTest.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateWithStringColumnIndexes() throws SQLException {
    CallableStatement preparedStatement = swConnection.prepareCall("UPDATE test SET  a = ?");

    int updateCount = preparedStatement.executeUpdate("UPDATE test SET  a = 1", new String[] {"1"});
    preparedStatement.cancel();
    preparedStatement.close();

    verify(mysqlCallableStatement).close();
    assertThat(segmentStorage.getTraceSegments().size(), is(1));
    TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
    List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
    assertThat(spans.size(), is(1));
    assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeUpdate", "UPDATE test SET  a = 1");
}