Hyperic HQ Plugin API v. 2.5.dev

## net.hyperic.hq.product
Class JDBCMeasurementPlugin

    java.lang.Object
      net.hyperic.hq.product.GenericPlugin
          net.hyperic.hq.product.MeasurementPlugin
              net.hyperic.hq.product.SigarMeasurementPlugin
                  net.hyperic.hq.product.JDBCMeasurementPlugin

public abstract class JDBCMeasurementPlugin
extends SigarMeasurementPlugin

Base class for JDBC measurement plugins. Abstracts the JDBC connection and query functionality.

Field Summary
`protected static java.lang.String` `AVAIL_ATTR`
`static int` `COL_INVALID`
`static java.lang.String` `PROP_PASSWORD`
`static java.lang.String` `PROP_TABLE`
`static java.lang.String` `PROP_URL`
`static java.lang.String` `PROP_USER`

Fields inherited from class net.hyperic.hq.product.SigarMeasurementPlugin
`manager, PTQL_CONFIG, PTQL_DOMAIN, VALUE_NOTIMPL`

Fields inherited from class net.hyperic.hq.product.MeasurementPlugin
`PROP_TEMPLATE_CONFIG`

Fields inherited from class net.hyperic.hq.product.GenericPlugin
`config, FILE_DELIM, FILE_DELIM_ESC, PROP_NAME`

Constructor Summary
`JDBCMeasurementPlugin()`

Method Summary
`protected java.sql.Connection` `getCachedConnection(java.lang.String url, java.lang.String user, java.lang.String pass)`
`protected int` `getColumn(Metric jdsn)` The column in the ResultSet that holds the measurement value.
`protected java.lang.String` `getColumnName(Metric jdsn)`
`ConfigSchema` `getConfigSchema(TypeInfo info, ConfigResponse config)` Config schema includes jdbc URL, database username and password.
`protected abstract java.sql.Connection` `getConnection(java.lang.String url, java.lang.String user, java.lang.String password)` The plugin must preform the DriverManager.getConnection so its ClassLoader is used to find the driver.
`protected abstract java.lang.String` `getDefaultURL()`
`protected abstract void` `getDriver()` The plugin must preform the Class.forName so its ClassLoader is used to find the driver.
`protected abstract java.lang.String` `getQuery(Metric jdsn)`
`protected double` `getQueryValue(Metric jdsn)` Do the database query returned by the getQuery() method and return the result.
`MetricValue` `getValue(Metric metric)` Dispatches to getQueryValue()
`void` `init(PluginManager manager)` Verifies that JDBC driver returned by the getDriver() method can be loaded by the plugin.
`protected abstract void` `initQueries()`
`protected void` `removeCachedConnection(java.lang.String url, java.lang.String user, java.lang.String pass)`
`void` `shutdown()` Close any cached connections.

Methods inherited from class net.hyperic.hq.product.SigarMeasurementPlugin
`getSigar, translate`

Methods inherited from class net.hyperic.hq.product.MeasurementPlugin
`getHelp, getManager, getMeasurementProperties, getMeasurements, getPlatformHelpProperties, getPluginXMLHelp`

Methods inherited from class net.hyperic.hq.product.GenericPlugin

`configure, getAbsoluteFiles, getConfig, getConfig, getCustomPropertiesSchema, getCustomPropertiesSchema, getCustomPropertiesSchema, getDefaultInstallPath, getLog, getLogName, getName, getPlatformName, getPluginClassName, getProductPlugin, getProperties, getProperty, getTypeInfo, getTypeNameProperty, getTypeNameProperty, getTypeProperty, getTypeProperty, getTypeProperty, isWin32, openResource, setName, setTypeInfo, toFileList`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### AVAIL_ATTR

    protected static final java.lang.String AVAIL_ATTR

See Also:
  Constant Field Values

### PROP_URL

    public static final java.lang.String PROP_URL

See Also:
  Constant Field Values

### PROP_USER

    public static final java.lang.String PROP_USER

See Also:
  Constant Field Values

### PROP_PASSWORD

    public static final java.lang.String PROP_PASSWORD

See Also:
  Constant Field Values

### PROP_TABLE

    public static final java.lang.String PROP_TABLE

See Also:
  Constant Field Values

### COL_INVALID

    public static final int COL_INVALID

See Also:
  Constant Field Values

Constructor Detail

### JDBCMeasurementPlugin

    public JDBCMeasurementPlugin()

Method Detail

### getConfigSchema

    public ConfigSchema getConfigSchema(TypeInfo info,
                                        ConfigResponse config)

  Config schema includes jdbc URL, database username and password. These values will be used to obtain a connection from DriverManager.getConnection.

  Overrides:
    `getConfigSchema` in class `MeasurementPlugin`

### init

    public void init(PluginManager manager)
              throws PluginException

  Verifies that JDBC driver returned by the getDriver() method can be loaded by the plugin.

  Overrides:
    `init` in class `SigarMeasurementPlugin`
  Throws:
    `PluginException`

### shutdown

    public void shutdown()
                  throws PluginException

  Close any cached connections.

  Overrides:
    `shutdown` in class `SigarMeasurementPlugin`
  Throws:
    `PluginException`

### getValue

    public MetricValue getValue(Metric metric)
                         throws PluginException,
                                MetricUnreachableException,
                                MetricInvalidException,
                                MetricNotFoundException

  Dispatches to getQueryValue()

  Overrides:
    `getValue` in class `SigarMeasurementPlugin`
  Throws:
    `PluginException`
    `MetricUnreachableException`
    `MetricInvalidException`
    `MetricNotFoundException`

### initQueries

    protected abstract void initQueries()

### getQuery

    protected abstract java.lang.String getQuery(Metric jdsn)

### getDriver

    protected abstract void getDriver()
                               throws java.lang.ClassNotFoundException

  The plugin must preform the Class.forName so its ClassLoader is used to find the driver.

  Throws:
    `java.lang.ClassNotFoundException`

### getConnection

    protected abstract java.sql.Connection getConnection(java.lang.String url,
                                                         java.lang.String user,
                                                         java.lang.String password)
                                                  throws java.sql.SQLException

  The plugin must preform the DriverManager.getConnection so its ClassLoader is used to find the driver.

  Throws:
    `java.sql.SQLException`

### getDefaultURL

    protected abstract java.lang.String getDefaultURL()

### getColumn

    protected int getColumn(Metric jdsn)

  The column in the ResultSet that holds the measurement value. For most plugins this will be 1, by some databases do not allow a ResultSet with a single column to be returned (see MySQL)

### getColumnName

    protected java.lang.String getColumnName(Metric jdsn)

### getCachedConnection

    protected java.sql.Connection getCachedConnection(java.lang.String url,
                                                      java.lang.String user,
                                                      java.lang.String pass)
                                               throws java.sql.SQLException

  Throws:
    `java.sql.SQLException`

### removeCachedConnection

    protected void removeCachedConnection(java.lang.String url,
                                          java.lang.String user,
                                          java.lang.String pass)

### getQueryValue

    protected double getQueryValue(Metric jdsn)
                            throws MetricNotFoundException,
                                   PluginException,
                                   MetricUnreachableException

  Do the database query returned by the getQuery() method and return the result. A cached connection will be used if one exists, otherwise the created connection will be cached for future use.

  Throws:
    `MetricNotFoundException`
    `PluginException`
    `MetricUnreachableException`

Hyperic HQ Plugin API v. 2.5.dev

Copyright © 2004-2005 Hyperic LLC support@hyperic.net, All Rights Reserved.