org.apache.jmeter.protocol.jdbc

## Class AbstractJDBCTestElement

- java.lang.Object
- - org.apache.jmeter.testelement.AbstractTestElement
  - - org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Searchable, TestElement, TestStateListener
  Direct Known Subclasses:
    AbstractJDBCProcessor, JDBCSampler

      public abstract class AbstractJDBCTestElement
      extends AbstractTestElement
      implements TestStateListener

  A base class for all JDBC test elements handling the basics of a SQL request.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static java.lang.String` | `ENCODING`

    - ### Fields inherited from interface org.apache.jmeter.testelement.TestElement

      `COMMENTS, ENABLED, GUI_CLASS, NAME, TEST_CLASS`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractJDBCTestElement()` Creates a JDBCSampler.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `close(java.sql.Connection c)`
    `static void` | `close(java.sql.ResultSet rs)`
    `static void` | `close(java.sql.Statement s)`
    `protected byte[]` | `execute(java.sql.Connection conn)` Execute the test element.
    `protected byte[]` | `execute(java.sql.Connection conn, SampleResult sample)` Execute the test element.
    `java.lang.String` | `getDataSource()`
    `int` | `getIntegerQueryTimeout()`
    `java.lang.String` | `getQuery()`
    `java.lang.String` | `getQueryArguments()`
    `java.lang.String` | `getQueryArgumentsTypes()`
    `java.lang.String` | `getQueryTimeout()`
    `java.lang.String` | `getQueryType()`
    `java.lang.String` | `getResultSetHandler()`
    `java.lang.String` | `getResultVariable()`
    `java.lang.String` | `getVariableNames()`
    `void` | `setDataSource(java.lang.String dataSource)`
    `void` | `setQuery(java.lang.String query)`
    `void` | `setQueryArguments(java.lang.String queryArguments)`
    `void` | `setQueryArgumentsTypes(java.lang.String queryArgumentsType)`
    `void` | `setQueryTimeout(java.lang.String queryTimeout)`
    `void` | `setQueryType(java.lang.String queryType)`
    `void` | `setResultSetHandler(java.lang.String resultSetHandler)`
    `void` | `setResultVariable(java.lang.String resultVariable)`
    `void` | `setVariableNames(java.lang.String variableNames)`
    `void` | `testEnded()` Called once for all threads after the end of a test.
    `void` | `testEnded(java.lang.String host)` Called once for all threads after the end of a test.
    `void` | `testStarted()` Called just before the start of the test from the main engine thread.
    `void` | `testStarted(java.lang.String host)` Called just before the start of the test from the main engine thread.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.apache.jmeter.testelement.AbstractTestElement

      `addPropertiesValues, addProperty, addProperty, addTestElement, canRemove, clear, clearTemporary, clearTestElementChildren, clone, emptyTemporary, equals, getComment, getName, getProperty, getPropertyAsBoolean, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsFloat, getPropertyAsInt, getPropertyAsInt, getPropertyAsLong, getPropertyAsLong, getPropertyAsString, getPropertyAsString, getSearchableTokens, getThreadContext, getThreadName, hashCode, isEnabled, isRunningVersion, isTemporary, logProperties, mergeIn, propertyIterator, recoverRunningVersion, removeProperty, setComment, setEnabled, setName, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setRunningVersion, setTemporary, setThreadContext, setThreadName, traverse, traverseCollection, traverseMap, traverseProperty`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.jmeter.testelement.TestElement

      `removed`

- - ### Field Detail

    - #### ENCODING

          protected static final java.lang.String ENCODING

  - ### Constructor Detail

    - #### AbstractJDBCTestElement

          protected AbstractJDBCTestElement()

      Creates a JDBCSampler.

  - ### Method Detail

    - #### execute

          protected byte[] execute(java.sql.Connection conn)
                            throws java.sql.SQLException,
                                   java.io.IOException,
                                   java.lang.UnsupportedOperationException

      Execute the test element.
      Parameters:
        `conn` - a `Connection`
      Returns:
        the result of the execute command
      Throws:
        `java.sql.SQLException` - if a database error occurs
        `java.io.IOException` - when I/O error occurs
        `java.lang.UnsupportedOperationException` - if the user provided incorrect query type

    - #### execute

          protected byte[] execute(java.sql.Connection conn,
                                   SampleResult sample)
                            throws java.sql.SQLException,
                                   java.io.IOException,
                                   java.lang.UnsupportedOperationException

      Execute the test element. Use the sample given as argument to set time to first byte in the "latency" field of the SampleResult.
      Parameters:
        `conn` - a `Connection`
        `sample` - a `SampleResult` to save the latency
      Returns:
        the result of the execute command
      Throws:
        `java.sql.SQLException` - if a database error occurs
        `java.io.IOException` - when I/O error occurs
        `java.lang.UnsupportedOperationException` - if the user provided incorrect query type

    - #### close

          public static void close(java.sql.Connection c)

    - #### close

          public static void close(java.sql.Statement s)

    - #### close

          public static void close(java.sql.ResultSet rs)

    - #### getIntegerQueryTimeout

          public int getIntegerQueryTimeout()

      Returns:
        the integer representation queryTimeout

    - #### getQueryTimeout

          public java.lang.String getQueryTimeout()

      Returns:
        the queryTimeout

    - #### setQueryTimeout

          public void setQueryTimeout(java.lang.String queryTimeout)

      Parameters:
        `queryTimeout` - query timeout in seconds

    - #### getQuery

          public java.lang.String getQuery()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### setQuery

          public void setQuery(java.lang.String query)

      Parameters:
        `query` - The query to set.

    - #### getDataSource

          public java.lang.String getDataSource()

      Returns:
        Returns the dataSource.

    - #### setDataSource

          public void setDataSource(java.lang.String dataSource)

      Parameters:
        `dataSource` - The dataSource to set.

    - #### getQueryType

          public java.lang.String getQueryType()

      Returns:
        Returns the queryType.

    - #### setQueryType

          public void setQueryType(java.lang.String queryType)

      Parameters:
        `queryType` - The queryType to set.

    - #### getQueryArguments

          public java.lang.String getQueryArguments()

    - #### setQueryArguments

          public void setQueryArguments(java.lang.String queryArguments)

    - #### getQueryArgumentsTypes

          public java.lang.String getQueryArgumentsTypes()

    - #### setQueryArgumentsTypes

          public void setQueryArgumentsTypes(java.lang.String queryArgumentsType)

    - #### getVariableNames

          public java.lang.String getVariableNames()

      Returns:
        the variableNames

    - #### setVariableNames

          public void setVariableNames(java.lang.String variableNames)

      Parameters:
        `variableNames` - the variableNames to set

    - #### getResultSetHandler

          public java.lang.String getResultSetHandler()

      Returns:
        the resultSetHandler

    - #### setResultSetHandler

          public void setResultSetHandler(java.lang.String resultSetHandler)

      Parameters:
        `resultSetHandler` - the resultSetHandler to set

    - #### getResultVariable

          public java.lang.String getResultVariable()

      Returns:
        the resultVariable

    - #### setResultVariable

          public void setResultVariable(java.lang.String resultVariable)

      Parameters:
        `resultVariable` - the variable name in which results will be stored

    - #### testStarted

          public void testStarted()

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testStarted` in interface `TestStateListener`
      See Also:
        `TestStateListener.testStarted()`

    - #### testStarted

          public void testStarted(java.lang.String host)

      Called just before the start of the test from the main engine thread. This is before the test elements are cloned. Note that not all the test variables will have been set up at this point.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testStarted` in interface `TestStateListener`
      Parameters:
        `host` - name of host
      See Also:
        `TestStateListener.testStarted(java.lang.String)`

    - #### testEnded

          public void testEnded()

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testEnded` in interface `TestStateListener`
      See Also:
        `TestStateListener.testEnded()`

    - #### testEnded

          public void testEnded(java.lang.String host)

      Called once for all threads after the end of a test. This will use the same element instances as at the start of the test.

      N.B. testStarted() and testEnded() are called from different threads.

      Specified by:
        `testEnded` in interface `TestStateListener`
      Parameters:
        `host` - name of host
      See Also:
        `TestStateListener.testEnded(java.lang.String)`

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.