Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 5.8.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.hq.product
Class JDBCMeasurementPlugin

    java.lang.Object
      org.hyperic.hq.product.GenericPlugin
          org.hyperic.hq.product.MeasurementPlugin
              org.hyperic.hq.product.JDBCMeasurementPlugin

    public abstract class JDBCMeasurementPlugin

extends MeasurementPlugin

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

Field Summary
`protected String` | `_sqlLog`
`protected static String` | `AVAIL_ATTR`
`static int` | `COL_INVALID`
`static String` | `PROP_INDEX`
`static String` | `PROP_PASSWORD`
`static String` | `PROP_TABLE`
`static String` | `PROP_URL`
`static String` | `PROP_USER`

Fields inherited from class org.hyperic.hq.product.MeasurementPlugin
`PROP_TEMPLATE_CONFIG, TYPE_COLLECTOR`

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

Constructor Summary
`JDBCMeasurementPlugin()`

Method Summary
`protected Connection` | `getCachedConnection(Metric metric)`
`protected Connection` | `getCachedConnection(String url, String user, String pass)`
`protected int` | `getColumn(Metric jdsn)` The column in the ResultSet that holds the measurement value.
`protected String` | `getColumnName(Metric jdsn)`
`org.hyperic.util.config.ConfigSchema` | `getConfigSchema(TypeInfo info, org.hyperic.util.config.ConfigResponse config)` Config schema includes jdbc URL, database username and password.
`protected abstract Connection` | `getConnection(String url, String user, String password)` The plugin must preform the DriverManager.getConnection so its ClassLoader is used to find the driver.
`protected abstract String` | `getDefaultURL()`
`protected abstract void` | `getDriver()` The plugin must preform the Class.forName so its ClassLoader is used to find the driver.
`static Properties` | `getJDBCConnectionProperties(String user, String password)` Utility method that returns an instance of Properties containing the given user and password keys.
`protected abstract String` | `getQuery(Metric jdsn)`
`protected double` | `getQueryValue(Metric jdsn)` Do the database query returned by the getQuery() method and return the result.
`protected double` | `getQueryValue(Metric jdsn, boolean logSql)`
`org.hyperic.hq.product.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` | `processColumnHeader(ResultSetMetaData md)`
`protected void` | `processColumns(ResultSet rs)`
`protected void` | `removeCachedConnection(String url, String user, String pass)`
`protected void` | `returnCachedConnection(String url, String user, String pass, Connection conn)`
`protected void` | `setData(ResultSet rs)`
`void` | `shutdown()` Close any cached connections.

Methods inherited from class org.hyperic.hq.product.MeasurementPlugin
`getCollectorProperties, getHelp, getManager, getMeasurementProperties, getMeasurements, getNewCollector, getPlatformHelpProperties, getPluginXMLHelp, translate`

Methods inherited from class org.hyperic.hq.product.GenericPlugin
`adjustClassPath, configure, getAbsoluteFiles, getConfig, getConfig, getCustomPropertiesSchema, getCustomPropertiesSchema, getCustomPropertiesSchema, getDefaultInstallPath, getLog, getLogName, getManagerProperty, getName, getPlatformName, getPluginClassName, getPluginData, getPluginProperty, getPluginVersion, getProductPlugin, getProperties, getScriptExtension, getScriptExtension, getScriptExtension, getTypeInfo, getTypeNameProperty, getTypeNameProperty, getTypeProperties, getTypeProperty, getTypeProperty, getTypeProperty, isNetStatEnabled, isWin32, openResource, setData, setName, setPluginVersion, 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 String AVAIL_ATTR

See Also:
  Constant Field Values

### PROP_URL

    public static final String PROP_URL

See Also:
  Constant Field Values

### PROP_USER

    public static final String PROP_USER

See Also:
  Constant Field Values

### PROP_PASSWORD

    public static final String PROP_PASSWORD

See Also:
  Constant Field Values

### PROP_TABLE

    public static final String PROP_TABLE

See Also:
  Constant Field Values

### PROP_INDEX

    public static final String PROP_INDEX

See Also:
  Constant Field Values

### COL_INVALID

    public static final int COL_INVALID

See Also:
  Constant Field Values

### _sqlLog

    protected String _sqlLog

Constructor Detail

### JDBCMeasurementPlugin

    public JDBCMeasurementPlugin()

Method Detail

### getConfigSchema

    public org.hyperic.util.config.ConfigSchema getConfigSchema(TypeInfo info,
                                                                org.hyperic.util.config.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`
  Parameters:
    `info` - The TypeInfo of this plugin from ProductPlugin.getTypes
    `config` - ConfigReponse of the parent resource (if any).
  Returns:
    ConfigSchema for this resource.

### 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 `MeasurementPlugin`
  Parameters:
    `manager` - The plugin manager for this plugin type.
  Throws:
    `PluginException`

### shutdown

    public void shutdown()
                  throws PluginException

  Close any cached connections.

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

### getValue

    public org.hyperic.hq.product.MetricValue getValue(Metric metric)
                                                throws PluginException,
                                                       MetricUnreachableException,
                                                       MetricInvalidException,
                                                       MetricNotFoundException

  Dispatches to getQueryValue()

  Overrides:
    `getValue` in class `MeasurementPlugin`
  Parameters:
    `metric` - Value returned from translate(), representing a specific metric to retrieve
  Returns:
    The value of the Metric and timestamp of collection time
  Throws:
    `PluginException` - Thrown when an internal plugin error occurs
    `MetricUnreachableException` - The monitored resource is unreachable. I.e. ConnectException
    `MetricInvalidException` - The plugin is unable to use the metric, generally a developer bug where the template is malformed. I.e. JMX MalformedObjectNameException
    `MetricNotFoundException` - The monitored resource does not know about the requested Metric. I.e. JMX AttributeNotFoundException

### initQueries

    protected abstract void initQueries()

### getQuery

    protected abstract String getQuery(Metric jdsn)

### getDriver

    protected abstract void getDriver()
                               throws ClassNotFoundException

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

  Throws:
    `ClassNotFoundException`

### getConnection

    protected abstract Connection getConnection(String url,
                                                String user,
                                                String password)
                                         throws SQLException

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

  Throws:
    `SQLException`

### getDefaultURL

    protected abstract 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 String getColumnName(Metric jdsn)

### getCachedConnection

    protected Connection getCachedConnection(Metric metric)
                                      throws SQLException

  Throws:
    `SQLException`

### getCachedConnection

    protected Connection getCachedConnection(String url,
                                             String user,
                                             String pass)
                                      throws SQLException

  Throws:
    `SQLException`

### removeCachedConnection

    protected void removeCachedConnection(String url,
                                          String user,
                                          String pass)

### returnCachedConnection

    protected void returnCachedConnection(String url,
                                          String user,
                                          String pass,
                                          Connection conn)

### 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`

### getQueryValue

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

  Throws:
    `MetricNotFoundException`
    `PluginException`
    `MetricUnreachableException`

### setData

    protected void setData(ResultSet rs)
                    throws SQLException

  Throws:
    `SQLException`

### processColumnHeader

    protected void processColumnHeader(ResultSetMetaData md)
                                throws SQLException

  Throws:
    `SQLException`

### processColumns

    protected void processColumns(ResultSet rs)
                           throws SQLException

  Throws:
    `SQLException`

### getJDBCConnectionProperties

    public static Properties getJDBCConnectionProperties(String user,
                                                         String password)

  Utility method that returns an instance of Properties containing the given user and password keys. The Properties instance returned can be passed in as the info argument to DriverManager.getConnection(url, info).

  Parameters:
    `user` - the username for the JDBC connection
    `password` - the password for the JDBC connection
  Returns:
    an instance of Properties containing the user and password JDBC Connection properties

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 5.8.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2010 Hyperic, Inc. support@hyperic.net, All Rights Reserved.