org.rhq.plugins.database
Class DatabaseQueryUtility

java.lang.Object
  extended by org.rhq.plugins.database.DatabaseQueryUtility

public class DatabaseQueryUtility
extends Object

Author:
Greg Hinkle

Nested Class Summary
static class DatabaseQueryUtility.StatementParameter
           
 
Constructor Summary
DatabaseQueryUtility()
           
 
Method Summary
static void close(Statement statement, ResultSet resultSet)
           
static int executeUpdate(DatabaseComponent databaseComponent, String query, Object... parameters)
           
static String[] getColumns(ResultSetMetaData rsmd)
           
static Map<String,Double> getNumericQueryValueMap(DatabaseComponent databaseComponent, String query, Object... parameters)
          Used to access a set of rows as key, value pairs where the key is the first column and is a string and the second is a value and is numeric
static Map<String,Double> getNumericQueryValues(DatabaseComponent databaseComponent, String query, Object... parameters)
          Used to read a single row of columns into a map
static Double getSingleNumericQueryValue(DatabaseComponent databaseComponent, String query, Object... parameters)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseQueryUtility

public DatabaseQueryUtility()
Method Detail

executeUpdate

public static int executeUpdate(DatabaseComponent databaseComponent,
                                String query,
                                Object... parameters)
                         throws SQLException
Throws:
SQLException

getSingleNumericQueryValue

public static Double getSingleNumericQueryValue(DatabaseComponent databaseComponent,
                                                String query,
                                                Object... parameters)

getNumericQueryValues

public static Map<String,Double> getNumericQueryValues(DatabaseComponent databaseComponent,
                                                       String query,
                                                       Object... parameters)
Used to read a single row of columns into a map

Parameters:
databaseComponent -
query -
parameters -
Returns:

getNumericQueryValueMap

public static Map<String,Double> getNumericQueryValueMap(DatabaseComponent databaseComponent,
                                                         String query,
                                                         Object... parameters)
Used to access a set of rows as key, value pairs where the key is the first column and is a string and the second is a value and is numeric

Parameters:
databaseComponent - the component to execute on
query - the sql query to run
parameters - any parameters to bind first
Returns:
a Map of the keys against the value

getColumns

public static String[] getColumns(ResultSetMetaData rsmd)
                           throws SQLException
Throws:
SQLException

close

public static void close(Statement statement,
                         ResultSet resultSet)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.