|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.echo2.table.DatabaseHelper
public class DatabaseHelper
A helper class for DatabaseTableModel to abstract JDBC
interactions.
© Copyright 2007 Sans Pareil Technologies, Inc.
| Constructor Summary | |
|---|---|
DatabaseHelper()
|
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseHelper()
| Method Detail |
|---|
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.util.List, java.util.List)
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 DatabaseTableModel
table - 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.
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||