|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.windward.datasource.jdbc.JdbcDataSource
This supplies a data source to Windward Reports using jdbc. The DataSourceProvider class is built on the concept of
xml nodes. For this class, a node is a ResultSet returned by a jdbc call to Statement.executeQuery().
An xml file always has the concept of the current node. This is not the case with a sql database - there is no current
ResultSet. A ResultSet is only generated by the wr:query and the wr:foreach tags. Therefore, all other tags only
make sense if they use the var attribute from a query or foreach to identify the ResultSet they are to be applied
to. A tag not identifying a ResultSet will throw an exception.
A query or foreach tag can reference a var from another query or foreach tag using ${var.item}.. An XPath query can
describe a node as well as an element. In this class a query defines a ResultSet and is only an element.
Also, with xml you can use xpath in each tag performing complex logic in determining what text to return. It
is very different for sql. The foreach or query can have complex logic. But the other tags can only return
an element from a result set that the foreach/query earlier returned or do a single select.
When using a var (<wr:forEach var="result"/>) that identifies a result set, you can use the following in a tag:
return ResultSet.getInt(1) > 0;. This does not look at the select statement, it is the notEmpty="true" that
puts it in this mode.
Notes: statements are created using Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)
The TYPE_SCROLL_INSENSITIVE or TYPE_SCROLL_SENSITIVE setting is necessary in some jdbc drivers for ResultSet.isLast()
to function.
| Constructor Summary | |
JdbcDataSource(java.sql.Connection conn)
Create a DataSourceProvider that uses jdbc to access a SQL database. |
|
JdbcDataSource(java.lang.String className,
java.lang.String url)
Create a DataSourceProvider that uses jdbc to access a SQL database. |
|
JdbcDataSource(java.lang.String className,
java.lang.String url,
java.lang.String username,
java.lang.String password)
Create a DataSourceProvider that uses jdbc to access a SQL database. |
|
| Method Summary | |
java.lang.String |
addView(java.lang.String key,
java.lang.String select)
This creates a view using the passed in select statement. |
void |
close()
Called when processing is complete. |
java.lang.String |
dump()
Display the entire dataset. |
DataSourceNode |
getRootNode()
Returns the root node for this data set. |
TagAttributes[] |
getTagAttributes()
Returns the allowed attributes for all tags. |
void |
log()
Log all info about this datasource to debug. |
void |
setMap(java.util.Map map)
Adds a map that is used for ${variable} substitution. |
void |
validateTag(BaseTag xmlTag)
Verifys that a tag has all required attributes and no unknown attributes. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public JdbcDataSource(java.lang.String className,
java.lang.String url,
java.lang.String username,
java.lang.String password)
throws DataSourceException
className - The classname for the jdbc driver. An example would be sun.jdbc.odbc.JdbcOdbcDriverurl - The url of the of the database. An example would be jdbc:odbc:sampledbusername - The username to log in to the database. This can be an empty string.password - Thepassword to log in to the database. This can be an empty string.DataSourceException - thrown if anything goes wrong.
public JdbcDataSource(java.lang.String className,
java.lang.String url)
throws DataSourceException
className - The classname for the jdbc driver. An example would be sun.jdbc.odbc.JdbcOdbcDriverurl - The url of the of the database. An example would be jdbc:odbc:sampledbDataSourceException - thrown if anything goes wrong.public JdbcDataSource(java.sql.Connection conn)
conn - A connection to the sql database to use as the datasource.| Method Detail |
public TagAttributes[] getTagAttributes()
getTagAttributes in interface DataSourceProvider
public void validateTag(BaseTag xmlTag)
throws TagException
validateTag in interface DataSourceProviderxmlTag - The tag to checkTagException - thrown if illegal parameters passed in.public void setMap(java.util.Map map)
setMap in interface DataSourceProvidermap - The map of string pairs.
public java.lang.String addView(java.lang.String key,
java.lang.String select)
throws java.sql.SQLException
key - The ${name} used to reference this view.select - The select part of the sql statement to create the view. Example: "select * from INVENTORY where
PRICE > 10"public DataSourceNode getRootNode()
getRootNode in interface DataSourceProvider
public void close()
throws DataSourceException
close in interface DataSourceProvidernet.windward.datasource.DataSourceProviderDataSourceException - Could not retrieve the data. Generally wraps a SqlException or XpathException.public void log()
log in interface DataSourceProvider
public java.lang.String dump()
throws DataSourceException
dump in interface DataSourceProviderDataSourceException - thrown if has any problems reading the dataset.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||