|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.lib.sql.XConnection
public class XConnection
An XSLT extension that allows a stylesheet to access JDBC data. It is accessed by specifying a namespace URI as follows:
xmlns:sql="http://xml.apache.org/xalan/sql"From the stylesheet perspective, XConnection provides 3 extension functions: new(), query(), and close(). Use new() to call one of XConnection constructors, which establishes a JDBC driver connection to a data source and returns an XConnection object. Then use the XConnection object query() method to return a result set in the form of a row-set element. When you have finished working with the row-set, call the XConnection object close() method to terminate the connection.
Field Summary | |
---|---|
private static boolean |
DEBUG
Flag for DEBUG mode |
private java.sql.Connection |
m_Connection
The DBMS Connection used to produce this SQL Document. |
private ConnectionPool |
m_ConnectionPool
The Current Connection Pool in Use. |
private boolean |
m_DefaultPoolingEnabled
If a default Connection Pool is used. |
private java.lang.Exception |
m_Error
Allow the SQL Extensions to return null on error. |
private boolean |
m_FullErrors
If true then full information should be returned about errors and warnings in getError(). |
private boolean |
m_InlineVariables
|
private boolean |
m_IsDefaultPool
|
private boolean |
m_IsMultipleResultsEnabled
This flag will be used to indicate if multiple result sets are supported from the database. |
private boolean |
m_IsStatementCachingEnabled
This flag will be used to indicate if database preparedstatements should be cached. |
private boolean |
m_IsStreamingEnabled
This flag will be used to indicate to the SQLDocument to use Streaming mode. |
private SQLDocument |
m_LastSQLDocumentWithError
When the Stylesheet wants to review the errors from a paticular document, it asks the XConnection. |
private java.util.Vector |
m_OpenSQLDocuments
As we do queries, we will produce SQL Documents. |
private java.util.Vector |
m_ParameterList
For PreparedStatements, we need a place to to store the parameters in a vector. |
private ConnectionPoolManager |
m_PoolMgr
Let's keep a copy of the ConnectionPoolMgr in alive here so we are keeping the static pool alive We will also use this Pool Manager to register our default pools. |
private SQLQueryParser |
m_QueryParser
One a per XConnection basis there is a master QueryParser that is responsible for generating Query Parsers. |
Constructor Summary | |
---|---|
XConnection()
|
|
XConnection(ExpressionContext exprContext,
org.w3c.dom.NodeList list)
|
|
XConnection(ExpressionContext exprContext,
java.lang.String connPoolName)
Constructs a new XConnection and attempts to connect to a datasource as defined in the connect(ExpressionContext exprContext, String connPoolName)
method. |
|
XConnection(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL)
|
|
XConnection(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL,
org.w3c.dom.Element protocolElem)
|
|
XConnection(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL,
java.lang.String user,
java.lang.String password)
|
Method Summary | |
---|---|
void |
addParameter(java.lang.String value)
Add an untyped value to the parameter list. |
void |
addParameterFromElement(org.w3c.dom.Element e)
Add a single parameter to the parameter list formatted as an Element |
void |
addParameterFromElement(org.w3c.dom.NodeList nl)
Add a section of parameters to the Parameter List Do each element from the list |
private void |
addParameters(org.w3c.dom.Element elem)
|
void |
addParameterWithType(java.lang.String value,
java.lang.String Type)
Add a typed parameter to the parameter list. |
private void |
addTypeToData(java.lang.String typeInfo)
|
private SQLErrorDocument |
buildErrorDocument()
|
void |
clearParameters()
|
void |
close()
Close the connection to the data source. |
void |
close(ExpressionContext exprContext,
java.lang.Object doc)
Close the connection to the data source. |
XBooleanStatic |
connect(ExpressionContext exprContext,
org.w3c.dom.Element protocolElem)
|
XBooleanStatic |
connect(ExpressionContext exprContext,
org.w3c.dom.NodeList list)
|
XBooleanStatic |
connect(ExpressionContext exprContext,
java.lang.String name)
Returns an XConnection from either a user created org.apache.xalan.lib.sql.ConnectionPool or a JNDI datasource. |
XBooleanStatic |
connect(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL)
Create an XConnection object with just a driver and database URL. |
XBooleanStatic |
connect(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL,
org.w3c.dom.Element protocolElem)
Create an XConnection object with a connection protocol |
XBooleanStatic |
connect(ExpressionContext exprContext,
java.lang.String driver,
java.lang.String dbURL,
java.lang.String user,
java.lang.String password)
Create an XConnection object with user ID and password. |
void |
disableDefaultConnectionPool()
Deprecated. Use setFeature("default-pool-enabled", "false"); |
void |
disableStreamingMode()
Deprecated. Use setFeature("streaming", "false"); |
void |
enableDefaultConnectionPool()
Deprecated. Use setFeature("default-pool-enabled", "true"); |
void |
enableStreamingMode()
Deprecated. Use setFeature("streaming", "true"); |
protected void |
finalize()
|
ConnectionPool |
getConnectionPool()
Allow the SQL Document to retrive a connection to be used to build the SQL Statement. |
DTM |
getError()
Provide access to the last error that occued. |
java.lang.String |
getFeature(java.lang.String feature)
Get feature options for this XConnection. |
private void |
init(java.lang.String driver,
java.lang.String dbURL,
java.util.Properties prop)
Initilize is being called because we did not have an existing Connection Pool, so let's see if we created one already or lets create one ourselves. |
private void |
initFromElement(org.w3c.dom.Element e)
Allow the database connection information to be sepcified in the XML tree. |
private SQLDocument |
locateSQLDocument(ExpressionContext exprContext,
java.lang.Object doc)
When an SQL Document is returned as a DTM object, the XSL variable is actually assigned as a DTMIterator. |
DTM |
pquery(ExpressionContext exprContext,
java.lang.String queryString)
Execute a parameterized query statement by instantiating an |
DTM |
pquery(ExpressionContext exprContext,
java.lang.String queryString,
java.lang.String typeInfo)
Execute a parameterized query statement by instantiating an |
DTM |
query(ExpressionContext exprContext,
java.lang.String queryString)
Execute a query statement by instantiating an |
void |
setError(java.lang.Exception excp,
ExpressionContext expr)
This is an internal version of Set Error that is called withen XConnection where there is no SQLDocument created yet. |
void |
setError(java.lang.Exception excp,
SQLDocument doc,
java.sql.SQLWarning warn)
Set an error and/or warning on this connection. |
void |
setFeature(java.lang.String feature,
java.lang.String setting)
Set feature options for this XConnection. |
void |
skipRec(ExpressionContext exprContext,
java.lang.Object o,
int value)
The purpose of this routine is to force the DB cursor to skip forward N records. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean DEBUG
private ConnectionPool m_ConnectionPool
private java.sql.Connection m_Connection
private boolean m_DefaultPoolingEnabled
private java.util.Vector m_OpenSQLDocuments
private ConnectionPoolManager m_PoolMgr
private java.util.Vector m_ParameterList
private java.lang.Exception m_Error
private SQLDocument m_LastSQLDocumentWithError
private boolean m_FullErrors
private SQLQueryParser m_QueryParser
private boolean m_IsDefaultPool
private boolean m_IsStreamingEnabled
private boolean m_InlineVariables
private boolean m_IsMultipleResultsEnabled
private boolean m_IsStatementCachingEnabled
Constructor Detail |
---|
public XConnection()
public XConnection(ExpressionContext exprContext, java.lang.String connPoolName)
connect(ExpressionContext exprContext, String connPoolName)
method.
org.apache.xalan.lib.sql.ConnectionPool
or a JNDI datasource.
exprContext
- Context automatically passed from the XSLT sheet.name
- The name of the ConnectionPool or the JNDI DataSource path.public XConnection(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL)
exprContext
- driver
- dbURL
- public XConnection(ExpressionContext exprContext, org.w3c.dom.NodeList list)
exprContext
- list
- public XConnection(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL, java.lang.String user, java.lang.String password)
exprContext
- driver
- dbURL
- user
- password
- public XConnection(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL, org.w3c.dom.Element protocolElem)
exprContext
- driver
- dbURL
- protocolElem
- Method Detail |
---|
public XBooleanStatic connect(ExpressionContext exprContext, java.lang.String name)
org.apache.xalan.lib.sql.ConnectionPool
or a JNDI datasource.
This method first tries to resolve the passed name against
ConnectionPool
s registered with
ConnectionPoolManager
.
If that fails, it attempts to find the name as a JNDI DataSource path.
exprContext
- Context automatically passed from the XSLT sheet.name
- The name of the ConnectionPool or the JNDI DataSource path.public XBooleanStatic connect(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL)
exprContext
- driver
- JDBC driver of the form foo.bar.Driver.dbURL
- database URL of the form jdbc:subprotocol:subname.public XBooleanStatic connect(ExpressionContext exprContext, org.w3c.dom.Element protocolElem)
exprContext
- protocolElem
- public XBooleanStatic connect(ExpressionContext exprContext, org.w3c.dom.NodeList list)
exprContext
- list
- public XBooleanStatic connect(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL, java.lang.String user, java.lang.String password)
exprContext
- driver
- JDBC driver of the form foo.bar.Driver.dbURL
- database URL of the form jdbc:subprotocol:subname.user
- user ID.password
- connection password.public XBooleanStatic connect(ExpressionContext exprContext, java.lang.String driver, java.lang.String dbURL, org.w3c.dom.Element protocolElem)
exprContext
- driver
- JDBC driver of the form foo.bar.Driver.dbURL
- database URL of the form jdbc:subprotocol:subname.protocolElem
- list of string tag/value connection arguments,
normally including at least "user" and "password".private void initFromElement(org.w3c.dom.Element e) throws java.sql.SQLException
e
-
java.sql.SQLException
private void init(java.lang.String driver, java.lang.String dbURL, java.util.Properties prop) throws java.sql.SQLException
driver
- dbURL
- prop
-
java.sql.SQLException
public ConnectionPool getConnectionPool()
public DTM query(ExpressionContext exprContext, java.lang.String queryString)
exprContext
- queryString
- the SQL query.
java.sql.SQLException
public DTM pquery(ExpressionContext exprContext, java.lang.String queryString)
exprContext
- queryString
- the SQL query.
java.sql.SQLException
public DTM pquery(ExpressionContext exprContext, java.lang.String queryString, java.lang.String typeInfo)
exprContext
- queryString
- the SQL query.typeInfo
-
java.sql.SQLException
public void skipRec(ExpressionContext exprContext, java.lang.Object o, int value)
exprContext
- o
- value
- private void addTypeToData(java.lang.String typeInfo)
public void addParameter(java.lang.String value)
value
- public void addParameterWithType(java.lang.String value, java.lang.String Type)
value
- Type
- public void addParameterFromElement(org.w3c.dom.Element e)
e
- public void addParameterFromElement(org.w3c.dom.NodeList nl)
nl
- private void addParameters(org.w3c.dom.Element elem)
elem
- public void clearParameters()
public void enableDefaultConnectionPool()
public void disableDefaultConnectionPool()
public void enableStreamingMode()
public void disableStreamingMode()
public DTM getError()
public void close() throws java.sql.SQLException
java.sql.SQLException
public void close(ExpressionContext exprContext, java.lang.Object doc) throws java.sql.SQLException
java.sql.SQLException
private SQLDocument locateSQLDocument(ExpressionContext exprContext, java.lang.Object doc)
doc
-
private SQLErrorDocument buildErrorDocument()
exprContext
- excp
- public void setError(java.lang.Exception excp, ExpressionContext expr)
public void setError(java.lang.Exception excp, SQLDocument doc, java.sql.SQLWarning warn)
public void setFeature(java.lang.String feature, java.lang.String setting)
feature
- The name of the feature being set, currently supports (streaming, inline-variables, multiple-results, cache-statements, default-pool-enabled).setting
- The new setting for the specified feature, currently "true" is true and anything else is false.public java.lang.String getFeature(java.lang.String feature)
feature
- The name of the feature to get the setting for.
protected void finalize()
finalize
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |