public class JdbcDataSource extends DataSourceBase implements DataSourceProvider
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.
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.prepareStatement(select, 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.| Modifier and Type | Class and Description | 
|---|---|
static class  | 
JdbcDataSource.JdbcSelect  | 
| Constructor and Description | 
|---|
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. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addSelectListener(JdbcSelectListener listener)
Adds a select Listener which is notified whenever a select has been executed. 
 | 
void | 
approveDenyModifySelect(BaseTag xmlTag)
Verifys that a tag select is approved by a user defined callback
 Or denies by throwing a DatasourceException or modifies the select 
 | 
void | 
close()
Called when processing is complete. 
 | 
java.sql.Connection | 
getConnection()  | 
java.lang.String | 
getDatasourceName()
returns the name of this type in the form "sql", "xml", etc. 
 | 
java.util.Map | 
getMap()
Returns the map of variables for this datasource. 
 | 
int | 
getParamMode()
Get the parameter substitution mode. 
 | 
int | 
getQueryMode(java.lang.String query,
            BaseTag tag)
Returns the query mode for this select. 
 | 
DataSourceNode | 
getRootNode()
Returns the root node for this data set. 
 | 
TagAttributes[] | 
getTagAttributes()
Returns the allowed attributes for all tags. 
 | 
void | 
populateDatasourceException(DataSourceException exception,
                           BaseTag tag,
                           DataSourceNode[] stack)
Populates that properties in a DataSourceException via DataSourceException.setProperties(). 
 | 
void | 
setDatasets(java.lang.Object[] datasets)
Set the datasets to use with this datasource. 
 | 
void | 
setMap(java.util.Map map)
Sets the map that is used for ${variable} substitution. 
 | 
void | 
setParamMode(int paramMode)
Set the parameter substitution mode. 
 | 
void | 
validateTag(BaseTag xmlTag)
Verifys that a tag has all required attributes and no unknown attributes. 
 | 
convertToInputStreampublic JdbcDataSource(java.lang.String className,
                      java.lang.String url,
                      java.lang.String username,
                      java.lang.String password)
               throws DataConnectionException
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.DataConnectionException - thrown if anything goes wrong.public JdbcDataSource(java.lang.String className,
                      java.lang.String url)
               throws DataConnectionException
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:sampledbDataConnectionException - thrown if anything goes wrong.public JdbcDataSource(java.sql.Connection conn)
               throws DataConnectionException
conn - A connection to the sql database to use as the datasource.DataConnectionExceptionpublic java.lang.String getDatasourceName()
getDatasourceName in interface DataSourceProviderpublic TagAttributes[] getTagAttributes()
getTagAttributes in interface DataSourceProviderpublic void validateTag(BaseTag xmlTag)
                 throws TagException,
                        DataSourceException
validateTag in interface DataSourceProviderxmlTag - The tag to checkTagException - thrown if illegal parameters passed in.DataSourceExceptionpublic void approveDenyModifySelect(BaseTag xmlTag)
                             throws DataSourceException
approveDenyModifySelect in interface DataSourceProviderxmlTag - The tag to checkDataSourceException - thrown if illegal parameters passed in.public void populateDatasourceException(DataSourceException exception, BaseTag tag, DataSourceNode[] stack)
populateDatasourceException in interface DataSourceProviderexception - The exception to populate.tag - The tag we're processing. null if no tag.stack - The node stack at the time of the exception. null if not relevant.public int getParamMode()
getParamMode in interface DataSourceProviderpublic void setParamMode(int paramMode)
setParamMode in interface DataSourceProviderparamMode - the parameter substitution mode.public void setMap(java.util.Map map)
setMap in interface DataSourceProvidermap - The map of string/value pairs.public java.util.Map getMap()
getMap in interface DataSourceProviderpublic void setDatasets(java.lang.Object[] datasets)
setDatasets in interface DataSourceProviderdatasets - The datasets to use. Can be null to turn off datasets. This is a JdbcDataset[] but because of
                 how the .NET engine is structured, we need to declare it as an object.public DataSourceNode getRootNode()
getRootNode in interface DataSourceProviderpublic void close()
           throws DataSourceException
close in interface DataSourceProviderDataSourceException - Could not retrieve the data. Generally wraps a SqlException or XpathException.public int getQueryMode(java.lang.String query,
                        BaseTag tag)
                 throws DataSourceException
getQueryMode in interface DataSourceProviderquery - The select to evaluate.tag - The tag this select is for. This may be null.DataSourceExceptionpublic java.sql.Connection getConnection()
public void addSelectListener(JdbcSelectListener listener)
Copyright © 2017 Windward Reports - All Rights Reserved. We are java reporting software