|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.openforecast.input.AbstractBuilder net.sourceforge.openforecast.input.ResultSetBuilder
public class ResultSetBuilder
Defines a Builder that can be used to construct a DataSet from a ResultSet. This class makes for a quick and easy "import" of data from a JDBC data source such as an Oracle database.
WARNING: This class has not been tested. It has been made available as a starting point for anyone interested in implementing this kind of Builder. It should work fine but, like I said, has not been tested. If you use this class and fine it works, as is, let me know (and perhaps I can remove this message). Alternatively, if you find any changes are necessary, please submit them for inclusion in the project.
Each record in the result set is assumed to define one data point. The last value on each row is assumed to represent the dependent variable. For example, if the independent variables are represented by x1, x2, x3 and so on, and the dependent variable is represented by y, then a row should be of the form:
x1, x2, ..., xi, y
For example, the following represents data points (1,3), (2,5), (3,6), and (4,7):
1, 3 2, 5 3, 6 4, 7
where the values 3, 5, 6 and 7 are the observed values of the dependent variable corresponding to the associated values of the independent variables with the values 1, 2, 3, and 4 respectively. The independent variables will be given the column names as defined by the query.
For example, consider the following query:
SELECT period, sales_revenue FROM sales_summaryThis would create a series of data points with the single independent variable,
period
. The sales_revenue
column is
assumed to represent the dependent variable (for which we don't currently
use the name).
Constructor Summary | |
---|---|
ResultSetBuilder(ResultSet resultSet)
Constructs a new ResultSetBuilder that reads its input from the given ResultSet. |
Method Summary | |
---|---|
DataSet |
build()
Retrieves a DataSet - a collection of DataPoints - from the current input source. |
Methods inherited from class net.sourceforge.openforecast.input.AbstractBuilder |
---|
addVariable, getNumberOfVariables, getVariableName, setNumberOfVariables, setVariableName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ResultSetBuilder(ResultSet resultSet)
resultSet
- the ResultSet containing data to be used to build the
DataSet.Method Detail |
---|
public DataSet build() throws SQLException
In general, build will attempt to convert all rows in the ResultSet to data points. In this implementation, all columns are assumed to contain numeric data. This restriction may be relaxed at a later date.
SQLException
- if a database access error occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |