public class DatabasePluginUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
DatabasePluginUtil.ComponentCannotProvideConnectionException |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canProvideConnection(ResourceComponent component) |
static Connection |
getConnectionFromComponent(ResourceComponent component)
Gets a
Connection from the component. |
static List<Map<String,Object>> |
getGridValues(ResourceComponent component,
String query,
Object... parameters)
Returns a list of values, one per row, containing a map of column names to values of that row.
|
static Map<String,Double> |
getNumericQueryValueMap(ResourceComponent component,
String query,
Object... parameters)
Returns a mapping of rows as key-value pairs where the key is the first column (a string) and the second column
is a value numeric.
|
static Map<String,Double> |
getNumericQueryValues(ResourceComponent component,
String query,
Object... parameters)
Executes a query, returning the results as a map where the keys are the column names and values are the value of
that column.
|
static Double |
getSingleNumericQueryValue(ResourceComponent component,
String query,
Object... parameters)
Returns the result of a query as a single Double value.
|
static boolean |
hasConnectionPoolingSupport(ResourceComponent component)
Determines if a resource component supports connection pooling.
|
static void |
safeClose(Connection connection) |
static void |
safeClose(Connection connection,
Statement statement) |
static void |
safeClose(Connection connection,
Statement statement,
ResultSet resultSet) |
static void |
safeClose(ResultSet resultSet) |
static void |
safeClose(Statement statement) |
public static boolean canProvideConnection(ResourceComponent component)
component is not null and supports connection pooling or is an instance of
DatabaseComponent.public static boolean hasConnectionPoolingSupport(ResourceComponent component)
component - the resource componentcomponent is not null, implements
ConnectionPoolingSupport and a call to
ConnectionPoolingSupport.supportsConnectionPooling() returns true.public static Connection getConnectionFromComponent(ResourceComponent component) throws SQLException
Connection from the component.component - a resource component that must be able to provide a Connection.SQLException - if component supports connection pooling and a pooled connection could not be
retrieved.IllegalArgumentException - if resource component is null or cannot provide a Connection (does not
support connection pooling and does not implement DatabaseComponent).public static Map<String,Double> getNumericQueryValues(ResourceComponent component, String query, Object... parameters)
component - query - SQL query stringparameters - optional bind parameterspublic static Map<String,Double> getNumericQueryValueMap(ResourceComponent component, String query, Object... parameters)
component - the component to execute onquery - the sql query to runparameters - any parameters to bind firstpublic static Double getSingleNumericQueryValue(ResourceComponent component, String query, Object... parameters)
Double.NaN if the query fails.public static List<Map<String,Object>> getGridValues(ResourceComponent component, String query, Object... parameters) throws SQLException
component - database to queryquery - SQL queryparameters - parameters to bind to the querySQLException - if query failspublic static void safeClose(Connection connection)
public static void safeClose(Connection connection, Statement statement)
public static void safeClose(Connection connection, Statement statement, ResultSet resultSet)
public static void safeClose(Statement statement)
public static void safeClose(ResultSet resultSet)
Copyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.