|
||||||||||
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
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 ConnectionPool |
m_ConnectionPool
The Current Connection Pool in Use. |
private boolean |
m_DefaultPoolingEnabled
If a default Connection Pool is used. i.e. |
private SQLErrorDocument |
m_Error
Allow the SQL Extensions to return null on error. |
private boolean |
m_IsDefaultPool
|
private boolean |
m_IsStreamingEnabled
This flag will be used to indicate to the SQLDocument to use Streaming mode. |
private Vector |
m_OpenSQLDocuments
As we do queries, we will produce SQL Documents. |
private 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. |
Constructor Summary | |
XConnection()
|
|
XConnection(ExpressionContext exprContext,
org.w3c.dom.NodeList list)
|
|
XConnection(ExpressionContext exprContext,
String ConnPoolName)
|
|
XConnection(ExpressionContext exprContext,
String driver,
String dbURL)
|
|
XConnection(ExpressionContext exprContext,
String driver,
String dbURL,
org.w3c.dom.Element protocolElem)
|
|
XConnection(ExpressionContext exprContext,
String driver,
String dbURL,
String user,
String password)
|
Method Summary | |
void |
addParameter(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(String value,
String Type)
Add a typed parameter to the parameter list. |
private void |
buildErrorDocument(ExpressionContext exprContext,
Exception excp)
|
private void |
buildErrorDocument(ExpressionContext exprContext,
SQLException excp)
|
void |
clearParameters()
|
void |
close()
Close the connection to the data source. |
void |
close(SQLDocument sqldoc)
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,
String ConnPoolName)
Create an XConnection using the name of an existing Connection Pool |
XBooleanStatic |
connect(ExpressionContext exprContext,
String driver,
String dbURL)
Create an XConnection object with just a driver and database URL. |
XBooleanStatic |
connect(ExpressionContext exprContext,
String driver,
String dbURL,
org.w3c.dom.Element protocolElem)
Create an XConnection object with a connection protocol |
XBooleanStatic |
connect(ExpressionContext exprContext,
String driver,
String dbURL,
String user,
String password)
Create an XConnection object with user ID and password. |
void |
disableDefaultConnectionPool()
See enableDefaultConnectionPool |
void |
disableStreamingMode()
Control how the SQL Document uses memory. |
void |
enableDefaultConnectionPool()
There is a problem with some JDBC drivers when a Connection is open and the JVM shutsdown. |
void |
enableStreamingMode()
Control how the SQL Document uses memory. |
protected void |
finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
DTM |
getError()
Provide access to the last error that occued. |
private void |
init(String driver,
String dbURL,
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. |
DTM |
pquery(ExpressionContext exprContext,
String queryString)
Execute a parameterized query statement by instantiating an |
DTM |
pquery(ExpressionContext exprContext,
String queryString,
String typeInfo)
Execute a parameterized query statement by instantiating an |
DTM |
query(ExpressionContext exprContext,
String queryString)
Execute a query statement by instantiating an |
void |
setParameter(int pos,
PreparedStatement stmt,
QueryParameter p)
Set the parameter for a Prepared Statement |
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 boolean m_DefaultPoolingEnabled
private Vector m_OpenSQLDocuments
private ConnectionPoolManager m_PoolMgr
private Vector m_ParameterList
private SQLErrorDocument m_Error
private boolean m_IsDefaultPool
private boolean m_IsStreamingEnabled
Constructor Detail |
public XConnection()
public XConnection(ExpressionContext exprContext, String ConnPoolName)
exprContext
- ConnPoolName
- public XConnection(ExpressionContext exprContext, String driver, String dbURL)
exprContext
- driver
- dbURL
- public XConnection(ExpressionContext exprContext, org.w3c.dom.NodeList list)
exprContext
- list
- public XConnection(ExpressionContext exprContext, String driver, String dbURL, String user, String password)
exprContext
- driver
- dbURL
- user
- password
- public XConnection(ExpressionContext exprContext, String driver, String dbURL, org.w3c.dom.Element protocolElem)
exprContext
- driver
- dbURL
- protocolElem
- Method Detail |
public XBooleanStatic connect(ExpressionContext exprContext, String ConnPoolName)
exprContext
- ConnPoolName
-
public XBooleanStatic connect(ExpressionContext exprContext, String driver, 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, String driver, String dbURL, String user, 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, String driver, 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 SQLException
e
-
SQLException
private void init(String driver, String dbURL, Properties prop) throws SQLException
driver
- dbURL
- prop
-
SQLException
public DTM query(ExpressionContext exprContext, String queryString)
exprContext
- queryString
- the SQL query.
SQLException
public DTM pquery(ExpressionContext exprContext, String queryString)
exprContext
- queryString
- the SQL query.
SQLException
public DTM pquery(ExpressionContext exprContext, String queryString, String typeInfo)
exprContext
- queryString
- the SQL query.typeInfo
-
SQLException
public void addParameter(String value)
value
-
public void addParameterWithType(String value, 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 SQLException
SQLException
public void close(SQLDocument sqldoc) throws SQLException
sqldoc
-
SQLException
public void setParameter(int pos, PreparedStatement stmt, QueryParameter p) throws SQLException
pos
- stmt
- p
-
SQLException
private void buildErrorDocument(ExpressionContext exprContext, SQLException excp)
exprContext
- excp
-
private void buildErrorDocument(ExpressionContext exprContext, Exception excp)
exprContext
- excp
-
protected void finalize()
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize is that it is invoked if and when the JavaTM virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.
The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.
The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.
After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
finalize
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |