Package org.jfree.data
Class JDBCCategoryDataset
java.lang.Object
org.jfree.data.AbstractDataset
org.jfree.data.DefaultCategoryDataset
org.jfree.data.JDBCCategoryDataset
- All Implemented Interfaces:
ObjectInputValidation
,Serializable
,Cloneable
,CategoryDataset
,Dataset
,KeyedValues2D
,Values2D
public class JDBCCategoryDataset extends DefaultCategoryDataset
A
CategoryDataset
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
category name and remaining columns values. executeQuery can be called a
number of times. The database connection is read-only and no write back
facility exists.- Author:
- Bryan Scott Changes ------- 24-Sep-2003 : Added clearing results from previous queries to executeQuery following being highlighted on online forum (BS);
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description JDBCCategoryDataset(String url, String driverName, String user, String passwd)
Creates a new dataset with a database connection.JDBCCategoryDataset(Connection connection)
Create a new dataset with the given database connection.JDBCCategoryDataset(Connection connection, String query)
Creates a new dataset with the given database connection, and executes the supplied query to populate the dataset. -
Method Summary
Modifier and Type Method Description void
executeQuery(String query)
Populates the dataset by executing the supplied query against the existing database connection.void
executeQuery(Connection con, String query)
Populates the dataset by executing the supplied query against the existing database connection.boolean
getTranspose()
Returns a flag that controls whether or not the table values are transposed when added to the dataset.void
setTranspose(boolean transpose)
Sets a flag that controls whether or not the table values are transposed when added to the dataset.Methods inherited from class org.jfree.data.DefaultCategoryDataset
addValue, addValue, clear, equals, getColumnCount, getColumnIndex, getColumnKey, getColumnKeys, getRowCount, getRowIndex, getRowKey, getRowKeys, getValue, getValue, hashCode, incrementValue, removeColumn, removeColumn, removeRow, removeRow, removeValue, setValue, setValue
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, getGroup, removeChangeListener, setGroup, validateObject
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
-
Constructor Details
-
JDBCCategoryDataset
public JDBCCategoryDataset(String url, String driverName, String user, String passwd) throws ClassNotFoundException, SQLExceptionCreates a new dataset with a database connection.- Parameters:
url
- the URL of the database connection.driverName
- the database driver class name.user
- the database user.passwd
- the database user's password.- Throws:
ClassNotFoundException
- if the driver cannot be found.SQLException
- if there is an error obtaining a connection to the database.
-
JDBCCategoryDataset
Create a new dataset with the given database connection.- Parameters:
connection
- the database connection.
-
JDBCCategoryDataset
Creates a new dataset with the given database connection, and executes the supplied query to populate the dataset.- Parameters:
connection
- the connection.query
- the query.- Throws:
SQLException
- if there is a problem executing the query.
-
-
Method Details
-
getTranspose
public boolean getTranspose()Returns a flag that controls whether or not the table values are transposed when added to the dataset.- Returns:
- A boolean.
-
setTranspose
public void setTranspose(boolean transpose)Sets a flag that controls whether or not the table values are transposed when added to the dataset.- Parameters:
transpose
- the flag.
-
executeQuery
Populates the dataset by executing the supplied query 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.- Throws:
SQLException
- if there is a problem executing the query.
-
executeQuery
Populates the dataset by executing the supplied query 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.query
- the query.- Throws:
SQLException
- if there is a problem executing the query.
-