JDBC Query Detector
The JDBCQueryDetector connects to a JDBC-enabled database and checks for any result from a user-specified SQL query.
If the query returns a result, the detector returns the detected
value.
If the query does not return a result, the detector returns the not detected
value.
Configuration and use
The JDBCQueryDetector uses the common configuration parameters.
Parameter | Description | Default value |
---|---|---|
Required |
||
dbDriver |
Database driver class name. |
org.postgresql.Driver |
password |
JDBC password. |
Empty String object. |
sqlQuery |
The SQL query to check. |
Empty String object. |
url |
JDBC URL to query. Note: this URL can differ based on JDBC drivers, databases, and so on. |
|
user |
JDBC username. |
postgres |
Optional |
||
port |
Port to query. |
3306 |
Database driver
The JDBCQueryDetector requires a JDBC driver to communicate with any database.
Horizon uses a PostgreSQL database, so the PostgreSQL JDBC driver is included out of the box.
For all other database systems, you must provide a compatible JDBC driver as a .jar
file.
To provide a JDBC driver, place the driver-jar in your ${OPENNMS_HOME}/lib
folder.
Examples
<detector name="MySQL-JDBC" class="org.opennms.netmgt.provision.detector.jdbc.JdbcQueryDetector">
<parameter key="password" value="borkborkbork"/>
<parameter key="user" value="opennms"/>
<parameter key="dbDriver" value="com.mysql.jdbc.Driver"/>
<parameter key="url" value="jdbc:mysql://OPENNMS_JDBC_HOSTNAME:3306/test"/>
<parameter key="sqlQuery" value="select * from nodes;"/>
<parameter key="timeout" value="5000"/>
</detector>
This example assumes you have loaded the MySQL driver file (see Install JDBC Driver).