public class JdbcDataSource extends AbstractDataSource
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_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
to function.Modifier and Type | Class and Description |
---|---|
class |
JdbcDataSource.JdbcNode |
static class |
JdbcDataSource.JdbcSelect |
rootNode
NAME_DATASET, NAME_JSON, NAME_LITERAL, NAME_ODATA, NAME_SFDC, NAME_SQL, NAME_XML, NAME_XML_1_0
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 |
close()
Called when processing is complete.
|
java.lang.String |
combineQueryForDataSet(java.lang.String dataSetQuery,
java.lang.String query,
java.lang.String dataSetName) |
java.sql.Connection |
getConnection() |
java.lang.String |
getDatasourceName()
returns the name of this type in the form "sql", "xml", etc.
|
IDataSourceQueryHelper |
getQueryHelper()
Returns the query helper which is datasource specific.
|
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.
|
boolean |
supportsDataSets()
Does this datasource support data sets?
|
approveDenyModifySelect, dataSourceNodeWithIndex, drillDownToVal, getParameters, getParamMode, getTagAttributes, populateDatasourceException, returnValue, SetDseProps, setParameters, setParamMode, validateTag
convertToInputStream, forTesting, getProperties, lookupVariable, setProperties
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProperties, setProperties
public 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.DataConnectionException
public java.lang.String getDatasourceName()
public java.lang.String combineQueryForDataSet(java.lang.String dataSetQuery, java.lang.String query, java.lang.String dataSetName)
combineQueryForDataSet
in class AbstractDataSource
public DataSourceNode getRootNode()
AbstractDataSource
getRootNode
in interface DataSourceProvider
getRootNode
in class AbstractDataSource
public IDataSourceQueryHelper getQueryHelper()
AbstractDataSource
getQueryHelper
in class AbstractDataSource
public void close()
close
in interface DataSourceProvider
close
in class AbstractDataSource
public int getQueryMode(java.lang.String query, BaseTag tag)
getQueryMode
in interface DataSourceProvider
getQueryMode
in class AbstractDataSource
query
- The select to evaluate.tag
- The tag this select is for. This may be null.public boolean supportsDataSets()
supportsDataSets
in class DataSourceBase
public java.sql.Connection getConnection()
public void addSelectListener(JdbcSelectListener listener)
Copyright © 2002-2021 Windward Studios, LLC. - All Rights Reserved. We are Java document generation software