public class JDBCPieDataset extends DefaultPieDataset
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.
| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
clear, clone, equals, getIndex, getItemCount, getKey, getKeys, getValue, getValue, hashCode, insertValue, insertValue, remove, setValue, setValue, sortByKeys, sortByValuesaddChangeListener, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObjectfinalize, getClass, notify, notifyAll, toString, wait, wait, waitaddChangeListener, getGroup, removeChangeListener, setGrouppublic JDBCPieDataset(java.lang.String url, java.lang.String driverName, java.lang.String user, java.lang.String password) throws java.sql.SQLException, java.lang.ClassNotFoundException
url - the URL of the database connection.driverName - the database driver class name.user - the database user.password - the database users password.java.lang.ClassNotFoundException - if the driver cannot be found.java.sql.SQLException - if there is a problem obtaining a database
connection.public JDBCPieDataset(java.sql.Connection con)
The dataset is initially empty, since no query has been supplied yet.
con - the database connection.public JDBCPieDataset(java.sql.Connection con, java.lang.String query) throws java.sql.SQLException
The dataset is initialised with the supplied query.
con - the database connection.query - the database connection.java.sql.SQLException - if there is a problem executing the query.public void executeQuery(java.lang.String query) throws java.sql.SQLException
query - the query to be executed.java.sql.SQLException - if there is a problem executing the query.public void executeQuery(java.sql.Connection con, java.lang.String query) throws java.sql.SQLException
query - the query to be executedcon - the connection the query is to be executed againstjava.sql.SQLException - if there is a problem executing the query.public void close()