Class ResultSetBuilder
- java.lang.Object
-
- net.sourceforge.openforecast.input.AbstractBuilder
-
- net.sourceforge.openforecast.input.ResultSetBuilder
-
- All Implemented Interfaces:
- Builder
public class ResultSetBuilder extends AbstractBuilder
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_summary
This would create a series of data points with the single independent variable,period. Thesales_revenuecolumn is assumed to represent the dependent variable (for which we don't currently use the name).- Since:
- 0.4
-
-
Constructor Summary
Constructors Constructor and Description ResultSetBuilder(java.sql.ResultSet resultSet)Constructs a new ResultSetBuilder that reads its input from the given ResultSet.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataSetbuild()Retrieves a DataSet - a collection of DataPoints - from the current input source.
-
-
-
Constructor Detail
-
ResultSetBuilder
public ResultSetBuilder(java.sql.ResultSet resultSet)
Constructs a new ResultSetBuilder that reads its input from the given ResultSet. The fields will be named according to the column labels defined by the ResultSet's meta data.- Parameters:
resultSet- the ResultSet containing data to be used to build the DataSet.
-
-
Method Detail
-
build
public DataSet build() throws java.sql.SQLException
Retrieves a DataSet - a collection of DataPoints - from the current input source. The DataSet should contain all DataPoints defined by the input source.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.
- Returns:
- a DataSet built from the current input source.
- Throws:
java.sql.SQLException- if a database access error occurs.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG