Package org.jfree.data.jdbc
Class JDBCPieDataset
java.lang.Object
org.jfree.data.general.AbstractDataset
org.jfree.data.general.DefaultPieDataset
org.jfree.data.jdbc.JDBCPieDataset
- All Implemented Interfaces:
ObjectInputValidation
,Serializable
,Cloneable
,PublicCloneable
,Dataset
,PieDataset
,KeyedValues
,Values
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.
- See Also:
-
Constructor Summary
ConstructorDescriptionJDBCPieDataset
(String url, String driverName, String user, String password) Creates a new JDBCPieDataset and establishes a new database connection.JDBCPieDataset
(Connection con) Creates a new JDBCPieDataset using a pre-existing database connection.JDBCPieDataset
(Connection con, String query) Creates a new JDBCPieDataset using a pre-existing database connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the database connectionvoid
executeQuery
(String query) ExecuteQuery will attempt execute the query passed to it against the existing database connection.void
executeQuery
(Connection con, String query) ExecuteQuery will attempt execute the query passed to it against the existing database connection.Methods inherited from class org.jfree.data.general.DefaultPieDataset
clear, clone, equals, getIndex, getItemCount, getKey, getKeys, getValue, getValue, hashCode, insertValue, insertValue, remove, setValue, setValue, sortByKeys, sortByValues
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
JDBCPieDataset
public JDBCPieDataset(String url, String driverName, String user, String password) throws SQLException, 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:
ClassNotFoundException
- if the driver cannot be found.SQLException
- if there is a problem obtaining a database connection.
-
JDBCPieDataset
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
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:
SQLException
- if there is a problem executing the query.
-
-
Method Details
-
executeQuery
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:
SQLException
- if there is a problem executing the query.
-
executeQuery
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:
con
- the connection the query is to be executed againstquery
- the query to be executed- Throws:
SQLException
- if there is a problem executing the query.
-
close
Close the database connection
-