Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jfree.data
Class JDBCXYDataset

    java.lang.Object
      org.jfree.data.AbstractDataset
          org.jfree.data.AbstractSeriesDataset
              org.jfree.data.AbstractXYDataset
                  org.jfree.data.JDBCXYDataset

All Implemented Interfaces:
  java.lang.Cloneable, Dataset, java.util.EventListener, java.io.ObjectInputValidation, RangeInfo, java.io.Serializable, SeriesChangeListener, SeriesDataset, TableXYDataset, XYDataset

public class JDBCXYDataset
extends AbstractXYDataset
implements XYDataset, TableXYDataset, RangeInfo

This class provides an `XYDataset` implementation over a database JDBC result set. The dataset is populated via a call to executeQuery with the string sql query. The sql query must return at least two columns. The first column will be the x-axis and remaining columns y-axis values. executeQuery can be called a number of times. The database connection is read-only and no write back facility exists.

See Also:
  Serialized Form

Constructor Summary
`JDBCXYDataset(java.sql.Connection con)` Creates a new dataset (initially empty) using the specified database connection.
`JDBCXYDataset(java.sql.Connection con, java.lang.String query)` Creates a new dataset using the specified database connection, and populates it using data obtained with the supplied query.
`JDBCXYDataset(java.lang.String url, java.lang.String driverName, java.lang.String user, java.lang.String password)` Creates a new dataset (initially empty) and establishes a new database connection.

Method Summary
`void` | `close()` Close the database connection
`void` | `executeQuery(java.sql.Connection con, java.lang.String query)` ExecuteQuery will attempt execute the query passed to it against the provided database connection.
`void` | `executeQuery(java.lang.String query)` ExecuteQuery will attempt execute the query passed to it against the existing database connection.
`int` | `getItemCount()` Returns the number of items in all series.
`int` | `getItemCount(int seriesIndex)` Returns the number of items in the specified series.
`int` | `getLegendItemCount()` Returns the number of items that should be displayed in the legend.
`java.lang.String[]` | `getLegendItemLabels()` Returns the legend item labels.
`java.lang.Number` | `getMaximumRangeValue()` Returns the maximum data value in the dataset's range.
`java.lang.Number` | `getMinimumRangeValue()` Returns the minimum data value in the dataset's range.
`int` | `getSeriesCount()` Returns the number of series in the dataset.
`java.lang.String` | `getSeriesName(int seriesIndex)` Returns the name of the specified series.
`Range` | `getValueRange()` Returns the range of the values in this dataset's range (y-values).
`java.lang.Number` | `getXValue(int seriesIndex, int itemIndex)` Returns the x-value for the specified series and item.
`java.lang.Number` | `getYValue(int seriesIndex, int itemIndex)` Returns the y-value for the specified series and item.
`boolean` | `isTimeSeries()` Returns `true` if the dataset represents time series data, and `false` otherwise.
`void` | `setTimeSeries(boolean timeSeries)` Sets a flag that indicates whether or not the data represents a time series.

Methods inherited from class org.jfree.data.AbstractXYDataset
`getX, getY`

Methods inherited from class org.jfree.data.AbstractSeriesDataset
`seriesChanged`

Methods inherited from class org.jfree.data.AbstractDataset
`addChangeListener, clone, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup, validateObject`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jfree.data.XYDataset
`getX, getY`

Methods inherited from interface org.jfree.data.Dataset
`addChangeListener, getGroup, removeChangeListener, setGroup`

Constructor Detail

### JDBCXYDataset

    public JDBCXYDataset(java.lang.String url,
                         java.lang.String driverName,
                         java.lang.String user,
                         java.lang.String password)
                  throws java.sql.SQLException,
                         java.lang.ClassNotFoundException

  Creates a new dataset (initially empty) and establishes a new database connection.

Parameters:
  `url` - URL of the database connection.
  `driverName` - the database driver class name.
  `user` - the database user.
  `password` - the database user's password.
Throws:
  `java.lang.ClassNotFoundException` - if the driver cannot be found.
  `java.sql.SQLException` - if there is a problem connecting to the database.

### JDBCXYDataset

    public JDBCXYDataset(java.sql.Connection con)
                  throws java.sql.SQLException

  Creates a new dataset (initially empty) using the specified database connection.

Parameters:
  `con` - the database connection.
Throws:
  `java.sql.SQLException` - if there is a problem connecting to the database.

### JDBCXYDataset

    public JDBCXYDataset(java.sql.Connection con,
                         java.lang.String query)
                  throws java.sql.SQLException

  Creates a new dataset using the specified database connection, and populates it using data obtained with the supplied query.

Parameters:
  `con` - the connection.
  `query` - the SQL query.
Throws:
  `java.sql.SQLException` - if there is a problem executing the query.

Method Detail

### isTimeSeries

    public boolean isTimeSeries()

  Returns `true` if the dataset represents time series data, and `false` otherwise.

  Returns:
    a boolean.

### setTimeSeries

    public void setTimeSeries(boolean timeSeries)

  Sets a flag that indicates whether or not the data represents a time series.

  Parameters:
    `timeSeries` - the new value of the flag.

### executeQuery

    public void executeQuery(java.lang.String query)
                      throws java.sql.SQLException

  ExecuteQuery will attempt execute the query passed to it against the existing database connection. If no connection exists then no action is taken. The results from the query are extracted and cached locally, thus applying an upper limit on how many rows can be retrieved successfully.

  Parameters:
    `query` - the query to be executed.
  Throws:
    `java.sql.SQLException` - if there is a problem executing the query.

### executeQuery

    public void executeQuery(java.sql.Connection con,
                             java.lang.String query)
                      throws java.sql.SQLException

  ExecuteQuery will attempt execute the query passed to it against the provided database connection. If connection is null then no action is taken The results from the query are extracted and cached locally, thus applying an upper limit on how many rows can be retrieved successfully.

  Parameters:
    `query` - the query to be executed.
    `con` - the connection the query is to be executed against.
  Throws:
    `java.sql.SQLException` - if there is a problem executing the query.

### getXValue

    public java.lang.Number getXValue(int seriesIndex,
                                      int itemIndex)

  Returns the x-value for the specified series and item. The implementation is responsible for ensuring that the x-values are presented in ascending order.

  Specified by:
    `getXValue` in interface `XYDataset`
  Parameters:
    `seriesIndex` - The series (zero-based index).
    `itemIndex` - The item (zero-based index).
  Returns:
    The x-value
  See Also:
    `XYDataset`

### getYValue

    public java.lang.Number getYValue(int seriesIndex,
                                      int itemIndex)

  Returns the y-value for the specified series and item.

  Specified by:
    `getYValue` in interface `XYDataset`
  Parameters:
    `seriesIndex` - The series (zero-based index).
    `itemIndex` - The item (zero-based index).
  Returns:
    The yValue value
  See Also:
    `XYDataset`

### getItemCount

    public int getItemCount(int seriesIndex)

  Returns the number of items in the specified series.

  Specified by:
    `getItemCount` in interface `XYDataset`
  Parameters:
    `seriesIndex` - The series (zero-based index).
  Returns:
    The itemCount value
  See Also:
    `XYDataset`

### getItemCount

    public int getItemCount()

  Returns the number of items in all series. This method is defined by the `TableXYDataset` interface.

  Specified by:
    `getItemCount` in interface `TableXYDataset`
  Returns:
    The item count.

### getSeriesCount

    public int getSeriesCount()

  Returns the number of series in the dataset.

  Specified by:
    `getSeriesCount` in interface `SeriesDataset`
  Specified by:
    `getSeriesCount` in class `AbstractSeriesDataset`
  Returns:
    The seriesCount value
  See Also:
    `XYDataset`, `Dataset`

### getSeriesName

    public java.lang.String getSeriesName(int seriesIndex)

  Returns the name of the specified series.

  Specified by:
    `getSeriesName` in interface `SeriesDataset`
  Specified by:
    `getSeriesName` in class `AbstractSeriesDataset`
  Parameters:
    `seriesIndex` - The series (zero-based index).
  Returns:
    The seriesName value
  See Also:
    `XYDataset`, `Dataset`

### getLegendItemCount

    public int getLegendItemCount()

  Returns the number of items that should be displayed in the legend.

  Returns:
    The legendItemCount value

### getLegendItemLabels

    public java.lang.String[] getLegendItemLabels()

  Returns the legend item labels.

  Returns:
    The legend item labels.

### getMinimumRangeValue

    public java.lang.Number getMinimumRangeValue()

  Returns the minimum data value in the dataset's range.

  Specified by:
    `getMinimumRangeValue` in interface `RangeInfo`
  Returns:
    The minimum value.
  See Also:
    `RangeInfo`

### getMaximumRangeValue

    public java.lang.Number getMaximumRangeValue()

  Returns the maximum data value in the dataset's range.

  Specified by:
    `getMaximumRangeValue` in interface `RangeInfo`
  Returns:
    The maximum value.
  See Also:
    `RangeInfo`

### close

    public void close()

  Close the database connection

### getValueRange

    public Range getValueRange()

  Returns the range of the values in this dataset's range (y-values).

  Specified by:
    `getValueRange` in interface `RangeInfo`
  Returns:
    The range.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD