org.apache.xalan.lib.sql
Class XConnection

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

public class XConnection
extends java.lang.Object

An XSLT extension that allows a stylesheet to access JDBC data. 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
 java.sql.Connection m_connection
          The JDBC connection.
 java.lang.String m_dbURL
          A database URL of the form jdbc:subprotocol:subname.
 java.lang.String m_driver
          A JDBC driver of the form "foo.bar.Driver".
 java.lang.String m_password
          A password.
 java.util.Properties m_protocol
          A list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.
 java.lang.String m_user
          A user ID.
 
Constructor Summary
XConnection(java.lang.String driver, java.lang.String dbURL)
          Create an XConnection object with just a driver and database URL.
XConnection(java.lang.String driver, java.lang.String dbURL, Element protocolElem)
          Create an XConnection object with a connection protocol
XConnection(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.
 
Method Summary
 void close()
          Close the connection to the data source.
 void connect(java.lang.String driver, java.lang.String dbURL, java.lang.String user, java.lang.String password, java.util.Properties protocol, int getConnectionArgs)
          Connect to the JDBC database.
 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_driver

public java.lang.String m_driver
A JDBC driver of the form "foo.bar.Driver".

m_dbURL

public java.lang.String m_dbURL
A database URL of the form jdbc:subprotocol:subname.

m_user

public java.lang.String m_user
A user ID.

m_password

public java.lang.String m_password
A password.

m_protocol

public java.util.Properties m_protocol
A list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.

m_connection

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

XConnection

public XConnection(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.

XConnection

public XConnection(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.

XConnection

public XConnection(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".
Method Detail

connect

public void connect(java.lang.String driver,
                    java.lang.String dbURL,
                    java.lang.String user,
                    java.lang.String password,
                    java.util.Properties protocol,
                    int getConnectionArgs)
Connect to the JDBC database.
Parameters:
driver - Database url of the form jdbc:subprotocol:subname .
dbURL - database URL of the form jdbc:subprotocol:subname.
user - user ID
password - connection password.
protocol - List of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included.
getConnectionArgs - Connection arguments

query

public NodeIterator query(java.lang.String queryString)
                   throws java.sql.SQLException
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.
Throws:
java.sql.SQLException -  

close

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


Copyright � 2000 Apache XML Project. All Rights Reserved.