org.apache.xalan.lib.sql
Class XConnection

java.lang.Object
  |
  +--org.apache.xalan.lib.sql.XConnection

public class XConnection
extends java.lang.Object

The XConnection Object is the main (currently the only) interface into the SQL Extensions from the Transformer. It is initiated by supplying connection information and is used by instructing it to produce a JDBC Query.

* The XConnection Object provides several methods of connecting to a JDBC Source. There are two major connection methods, one where the actual connection is established outside the scope of the trasformer XConnectionPoolManager and the other where the Connection information is supplied as part or either the XSLT Stylesheet or the XML Document.

If the Connection is part of an external connection, the connection is identified just by its connection pool name. In this mode, the connection pool manager will be interogated for the connection pool instance and a new connection is pulled from there.

When the Connection information is supplied from the Stylesheet or Document, the minimal amount of information that needs to be supplied is the JDBC class or driver and the URL to connect to that Driver.

Top maintain backward compatibility with previous versions of the extension, supplying connection information in the constructor is still supported.

The new method is to supply the connection information via the connect method.

Once a connection is established, a Database query must be performed to have data to work with. This can be accomplished in one of two way.

The straight query; the query method allow a simple query to be excuted. This methode qucikly becomes cumbersome when parts of the query are being created dynamically as part of the data but is easiest to implement for a simple static query.

The parameter based query; the pquery method allows the Stylesheet designer to create a simple query with place markers for the dynamic components. Form there the parameters are added in order. The pquery uses the JDBC prepated statement to do its work. Parmateres also allow the Stylesheet designer to specify the parameter type.


Field Summary
 java.sql.Connection m_connection
          The JDBC connection.
 
Constructor Summary
XConnection(NodeList list)
           
XConnection(java.lang.String ConnPoolName)
           
XConnection(java.lang.String driver, java.lang.String dbURL)
           
XConnection(java.lang.String driver, java.lang.String dbURL, Element protocolElem)
           
XConnection(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(Element e)
          Add a single parameter to the parameter list formatted as an Element
 void addParameterFromElement(NodeList nl)
          Add a section of parameters to the Parameter List Do each element from the list
 void addParameterWithType(java.lang.String value, java.lang.String Type)
          Add a typed parameter to the parameter list.
 void clearParameters()
          Clear the parameter list for the Prameter based queries.
 void close()
          Close the connection to the data source.
 NodeIterator connect(Element protocolElem)
           
 NodeIterator connect(NodeList list)
           
 NodeIterator connect(java.lang.String ConnPoolName)
          Create an XConnection using the name of an existing Connection Pool
 NodeIterator connect(java.lang.String driver, java.lang.String dbURL)
          Create an XConnection object with just a driver and database URL.
 NodeIterator connect(java.lang.String driver, java.lang.String dbURL, Element protocolElem)
          Create an XConnection object with a connection protocol
 NodeIterator connect(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 disableCacheNodes()
           
 void disableDefaultConnectionPool()
          See enableDefaultConnectionPool
 void enableCacheNodes()
           
 void enableDefaultConnectionPool()
          There is a problem with some JDBC drivers when a Connection is open and the JVM shutsdown.
 NodeIterator pquery(java.lang.String queryString)
          Execute a parameterized query statement by instantiating an XStatement object.
 NodeIterator pquery(java.lang.String queryString, java.lang.String typeInfo)
          Execute a parameterized query statement by instantiating an XStatement object.
 NodeIterator query(java.lang.String queryString)
          Execute a query statement by instantiating an XStatement object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_connection

public java.sql.Connection m_connection
The JDBC connection.
Constructor Detail

XConnection

public XConnection(java.lang.String ConnPoolName)

XConnection

public XConnection(java.lang.String driver,
                   java.lang.String dbURL)

XConnection

public XConnection(NodeList list)

XConnection

public XConnection(java.lang.String driver,
                   java.lang.String dbURL,
                   java.lang.String user,
                   java.lang.String password)

XConnection

public XConnection(java.lang.String driver,
                   java.lang.String dbURL,
                   Element protocolElem)
Method Detail

connect

public NodeIterator connect(java.lang.String ConnPoolName)
Create an XConnection using the name of an existing Connection Pool
Parameters:
String - poolName, name of the existing pool to pull connections from.

connect

public NodeIterator connect(java.lang.String driver,
                            java.lang.String dbURL)
Create an XConnection object with just a driver and database URL.
Parameters:
driver - JDBC driver of the form foo.bar.Driver.
dbURL - database URL of the form jdbc:subprotocol:subname.

connect

public NodeIterator connect(Element protocolElem)

connect

public NodeIterator connect(NodeList list)

connect

public NodeIterator connect(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.
Parameters:
driver - JDBC driver of the form foo.bar.Driver.
dbURL - database URL of the form jdbc:subprotocol:subname.
user - user ID.
password - connection password.

connect

public NodeIterator connect(java.lang.String driver,
                            java.lang.String dbURL,
                            Element protocolElem)
Create an XConnection object with a connection protocol
Parameters:
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".

query

public NodeIterator query(java.lang.String queryString)
Execute a query statement by instantiating an XStatement object. The XStatement executes the query, and uses the result set to create a RowSet, a row-set element.
Parameters:
queryString - the SQL query.
Returns:
XStatement implements NodeIterator.

pquery

public NodeIterator pquery(java.lang.String queryString)
Execute a parameterized query statement by instantiating an XStatement object. The XStatement executes the query, and uses the result set to create a RowSet, a row-set element.
Parameters:
queryString - the SQL query.
Returns:
XStatement implements NodeIterator.

pquery

public NodeIterator pquery(java.lang.String queryString,
                           java.lang.String typeInfo)
Execute a parameterized query statement by instantiating an XStatement object. The XStatement executes the query, and uses the result set to create a RowSet, a row-set element. This method allows for the user to pass in a comma seperated String that represents a list of parameter types. If supplied the parameter types will be used to overload the current types in the current parameter list.
Parameters:
queryString - the SQL query.
Returns:
XStatement implements NodeIterator.

addParameter

public void addParameter(java.lang.String value)
Add an untyped value to the parameter list.

addParameterWithType

public void addParameterWithType(java.lang.String value,
                                 java.lang.String Type)
Add a typed parameter to the parameter list.

addParameterFromElement

public void addParameterFromElement(Element e)
Add a single parameter to the parameter list formatted as an Element

addParameterFromElement

public void addParameterFromElement(NodeList nl)
Add a section of parameters to the Parameter List Do each element from the list

enableDefaultConnectionPool

public void enableDefaultConnectionPool()
There is a problem with some JDBC drivers when a Connection is open and the JVM shutsdown. If there is a problem, there is no way to control the currently open connections in the pool. So for the default connection pool, the actuall pooling mechinsm is disabled by default. The Stylesheet designer can re-enabled pooling to take advantage of connection pools. The connection pool can even be disabled which will close all outstanding connections.

disableDefaultConnectionPool

public void disableDefaultConnectionPool()
See enableDefaultConnectionPool

clearParameters

public void clearParameters()
Clear the parameter list for the Prameter based queries. Allows for XConnection reuse.

close

public void close()
           throws java.sql.SQLException
Close the connection to the data source.
Throws:
java.sql.SQLException -  

enableCacheNodes

public void enableCacheNodes()

disableCacheNodes

public void disableCacheNodes()


Copyright © 2000 Apache XML Project. All Rights Reserved.