public class DatabaseHelper extends Object
DatabaseTableModel to abstract JDBC
interactions.
© Copyright 2007 Sans Pareil Technologies, Inc.
| Constructor and Description |
|---|
DatabaseHelper() |
| Modifier and Type | Method and Description |
|---|---|
static RowSet |
getData(DataSource dataSource,
String schema,
String table,
List<String> primaryKeys,
List<String> columns,
List<String> orderBy,
int page,
int pageSize)
Fetch the data from the specified table.
|
static RowSet |
getData(String query,
DataSource dataSource,
String table,
List<String> primaryKeys,
int page,
int pageSize)
Fetch the data for the specified SQL statement.
|
static DataSource |
getDataSource(String name)
Return the
DataSource identified by the JNDI name
specified. |
static Collection<String> |
getPrimaryKeys(DataSource dataSource,
String schema,
String table)
Fetch the primary key columns for the specified table in the specified
schema.
|
static RowSet |
getRow(RowSet table,
DatabaseTableModel model)
Return a
RowSet that represents a single record
in the database table mapped by the specified DatabaseTableModel |
public static DataSource getDataSource(String name) throws NamingException
DataSource identified by the JNDI name
specified.name - The JNDI name to lookup.NamingException - If errors are encountered while fetching the
configured resource.public static Collection<String> getPrimaryKeys(DataSource dataSource, String schema, String table) throws SQLException
dataSource - The data source to use to fetch connections from.schema - The schema in which the table is defined.table - The table whose primary key columns are to be retrieved.SQLException - If errors are encountered while introspecting the
table.public static RowSet getData(String query, DataSource dataSource, String table, List<String> primaryKeys, int page, int pageSize) throws SQLException
query - The SQL statement that is to be executed.dataSource - The data source to use to fetch connection from.table - The table from which data is to be retrieved.primaryKeys - The columns that comprise the primary key for the
table.page - The page of data to retrieve from the database.pageSize - The size of one page of data.SQLException - If errors are encountered while fetch the data.public static RowSet getData(DataSource dataSource, String schema, String table, List<String> primaryKeys, List<String> columns, List<String> orderBy, int page, int pageSize) throws SQLException
Note: The RowSet.getMaxRows() method will
return the total number of rows available in the table.
dataSource - The data source to use to fetch connection from.schema - The schema in which the table is defined.table - The table from which data is to be retrieved.primaryKeys - The columns that comprise the primary key for the
table.columns - The columns that are to retrieved from the table.orderBy - The columns by which the data is to be ordered.page - The page of data to retrieve from the database.pageSize - The size of one page of data.SQLException - If errors are encountered while fetch the data.getQuery(java.lang.String, java.util.List<java.lang.String>, java.util.List<java.lang.String>, java.util.List<java.lang.String>)public static RowSet getRow(RowSet table, DatabaseTableModel model) throws NamingException, SQLException
RowSet that represents a single record
in the database table mapped by the specified DatabaseTableModeltable - The row set for the current page of data. This row
set cursor points to the row required.model - The table model from which primary key information
is retrieved.ResultSet.next() method has been invoked for convenience.NamingException - If errors are encountered while fetching the
data source.SQLException - If errors are encountered while fetching the data.