Class DataSourcePingTest

java.lang.Object
net.solarnetwork.dao.jdbc.DataSourcePingTest
All Implemented Interfaces:
PingTest

public class DataSourcePingTest extends Object implements PingTest
PingTest to verify a DataSource connection is available.

This test expects the configured query to return a Timestamp as the first column of the query result.

Since:
1.52
Version:
2.0
Author:
matt
  • Constructor Details

    • DataSourcePingTest

      public DataSourcePingTest(DataSource dataSource, String query)
      Constructor.

      The test ID will be set to the name of this class.

      Parameters:
      dataSource - the data source
      query - the query to execute
    • DataSourcePingTest

      public DataSourcePingTest(DataSource dataSource, String query, String id)
      Constructor.
      Parameters:
      dataSource - the data source
      query - the query to execute
      id - the test ID
      Since:
      1.1
  • Method Details

    • getPingTestId

      public String getPingTestId()
      Description copied from interface: PingTest
      Get some globally-unique ID for this test instance.
      Specified by:
      getPingTestId in interface PingTest
      Returns:
      The globally-unique ID of this test instance.
    • getPingTestName

      public String getPingTestName()
      Description copied from interface: PingTest
      Get display name for this test.
      Specified by:
      getPingTestName in interface PingTest
      Returns:
      The name of the test.
    • getPingTestMaximumExecutionMilliseconds

      public long getPingTestMaximumExecutionMilliseconds()
      Description copied from interface: PingTest
      Get the maximum number of milliseconds to wait for the ping test to execute before considering the test a failure.
      Specified by:
      getPingTestMaximumExecutionMilliseconds in interface PingTest
      Returns:
      The maximum execution milliseconds.
    • performPingTest

      public PingTest.Result performPingTest() throws Exception
      Description copied from interface: PingTest
      Perform the test, and return the results of the test.
      Specified by:
      performPingTest in interface PingTest
      Returns:
      The test results.
      Throws:
      Exception - if any error occurs
    • getQuery

      public String getQuery()
      Get the ping test SQL query.
      Returns:
      the SQL query