## org.jfree.data
Class JDBCPieDataset

    java.lang.Object
      org.jfree.data.AbstractDataset
          org.jfree.data.DefaultPieDataset
              org.jfree.data.JDBCPieDataset

All Implemented Interfaces:
  java.lang.Cloneable, Dataset, KeyedValues, java.io.ObjectInputValidation, PieDataset, java.io.Serializable, Values

public class JDBCPieDataset
extends DefaultPieDataset

A `PieDataset` that reads data from a database via JDBC.

A query should be supplied that returns data in two columns, the first containing VARCHAR data, and the second containing numerical data. The data is cached in-memory and can be refreshed at any time.

Author:
  Bryan Scott.
See Also:
  Serialized Form

Constructor Summary
`JDBCPieDataset(java.sql.Connection con)` Creates a new JDBCPieDataset using a pre-existing database connection.
`JDBCPieDataset(java.sql.Connection con, java.lang.String query)` Creates a new JDBCPieDataset using a pre-existing database connection.
`JDBCPieDataset(java.lang.String url, java.lang.String driverName, java.lang.String user, java.lang.String password)` Creates a new JDBCPieDataset 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 existing database connection.
`void` `executeQuery(java.lang.String query)` ExecuteQuery will attempt execute the query passed to it against the existing database connection.

Methods inherited from class org.jfree.data.DefaultPieDataset
`clone, equals, getIndex, getItemCount, getKey, getKeys, getValue, getValue, hashCode, setValue, setValue`

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

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

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

Constructor Detail

### JDBCPieDataset

    public JDBCPieDataset(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 JDBCPieDataset and establishes a new database connection.

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

### JDBCPieDataset

    public JDBCPieDataset(java.sql.Connection con)

  Creates a new JDBCPieDataset using a pre-existing database connection.

  The dataset is initially empty, since no query has been supplied yet.

Parameters:
  `con` - the database connection.

### JDBCPieDataset

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

  Creates a new JDBCPieDataset using a pre-existing database connection.

  The dataset is initialised with the supplied query.

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

Method Detail

### 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 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
    `con` - the connection the query is to be executed against
  Throws:
    `java.sql.SQLException` - if there is a problem executing the query.

### close

    public void close()

  Close the database connection