public class JDBCCategoryDataset extends DefaultCategoryDataset
CategoryDataset
implementation over a database JDBC result set.
The dataset is populated via a call to executeQuery(String)
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 (each
column represents a series). Subsequent calls to
executeQuery(String)
will refresh the dataset.
The database connection is read-only and no write back facility exists.
NOTE: Many people have found this class too restrictive in general use.
For the greatest flexibility, please consider writing your own code to read
data from a ResultSet
and populate a
DefaultCategoryDataset
directly.
Constructor and Description |
---|
JDBCCategoryDataset(java.sql.Connection connection)
Create a new dataset with the given database connection.
|
JDBCCategoryDataset(java.sql.Connection connection,
java.lang.String query)
Creates a new dataset with the given database connection, and executes
the supplied query to populate the dataset.
|
JDBCCategoryDataset(java.lang.String url,
java.lang.String driverName,
java.lang.String user,
java.lang.String passwd)
Creates a new dataset with a database connection.
|
Modifier and Type | Method and Description |
---|---|
void |
executeQuery(java.sql.Connection con,
java.lang.String query)
Populates the dataset by executing the supplied query against the
existing database connection.
|
void |
executeQuery(java.lang.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.
|
addValue, addValue, clear, clone, equals, getColumnCount, getColumnIndex, getColumnKey, getColumnKeys, getRowCount, getRowIndex, getRowKey, getRowKeys, getValue, getValue, hashCode, incrementValue, removeColumn, removeColumn, removeRow, removeRow, removeValue, setValue, setValue
addChangeListener, fireDatasetChanged, getGroup, getNotify, hasListener, notifyListeners, removeChangeListener, setGroup, setNotify, validateObject
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addChangeListener, getGroup, removeChangeListener, setGroup
public JDBCCategoryDataset(java.lang.String url, java.lang.String driverName, java.lang.String user, java.lang.String passwd) throws java.lang.ClassNotFoundException, java.sql.SQLException
url
- the URL of the database connection.driverName
- the database driver class name.user
- the database user.passwd
- the database user's password.java.lang.ClassNotFoundException
- if the driver cannot be found.java.sql.SQLException
- if there is an error obtaining a connection to the
database.public JDBCCategoryDataset(java.sql.Connection connection)
connection
- the database connection.public JDBCCategoryDataset(java.sql.Connection connection, java.lang.String query) throws java.sql.SQLException
connection
- the connection.query
- the query.java.sql.SQLException
- if there is a problem executing the query.public boolean getTranspose()
public void setTranspose(boolean transpose)
transpose
- the flag.public void executeQuery(java.lang.String query) throws java.sql.SQLException
The results from the query are extracted and cached locally, thus applying an upper limit on how many rows can be retrieved successfully.
query
- the query.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
The results from the query are extracted and cached locally, thus applying an upper limit on how many rows can be retrieved successfully.
con
- the connection.query
- the query.java.sql.SQLException
- if there is a problem executing the query.