org.apache.xalan.lib.sql
Class SQLDocument

java.lang.Object
  extended byorg.apache.xml.dtm.ref.DTMDefaultBase
      extended byorg.apache.xml.dtm.ref.DTMDefaultBaseTraversers
          extended byorg.apache.xml.dtm.ref.DTMDefaultBaseIterators
              extended byorg.apache.xalan.lib.sql.DTMDocument
                  extended byorg.apache.xalan.lib.sql.SQLDocument
All Implemented Interfaces:
DTM

public class SQLDocument
extends DTMDocument

The SQL Document is the main controlling class the executesa SQL Query


Nested Class Summary
 
Nested classes inherited from class org.apache.xalan.lib.sql.DTMDocument
DTMDocument.CharacterNodeHandler
 
Nested classes inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseIterators
 
Nested classes inherited from class org.apache.xml.dtm.ref.DTMDefaultBaseTraversers
 
Field Summary
private  boolean DEBUG
           
private  int m_Col_TypeID
           
private  int m_ColAttrib_CASESENSITIVE_TypeID
           
private  int m_ColAttrib_CATALOGUE_NAME_TypeID
           
private  int m_ColAttrib_COLUMN_LABEL_TypeID
           
private  int m_ColAttrib_COLUMN_NAME_TypeID
           
private  int m_ColAttrib_COLUMN_TYPE_TypeID
           
private  int m_ColAttrib_COLUMN_TYPENAME_TypeID
           
private  int m_ColAttrib_DEFINITLEYWRITEABLE_TypeID
           
private  int m_ColAttrib_DISPLAY_SIZE_TypeID
           
private  int m_ColAttrib_ISNULLABLE_TypeID
           
private  int m_ColAttrib_ISSEARCHABLE_TypeID
           
private  int m_ColAttrib_ISSIGNED_TypeID
           
private  int m_ColAttrib_ISWRITEABLE_TypeID
           
private  int m_ColAttrib_PRECISION_TypeID
           
private  int m_ColAttrib_SCALE_TypeID
           
private  int m_ColAttrib_SCHEMA_NAME_TypeID
           
private  int m_ColAttrib_TABLE_NAME_TypeID
           
private  int m_ColCount
          An indicator on how many columns are in this query
private  int[] m_ColHeadersIdx
          As the column header array is built, keep the node index for each Column.
private  int m_ColumnHeader_TypeID
           
private  Connection m_Connection
          The DBMS Connection used to produce this SQL Document.
private  ConnectionPool m_ConnectionPool
          The Connection Pool that originally produced the connection.
private  int m_FirstRowIdx
          Demark the first row element where we started adding rows into the Document.
private  int m_LastRowIdx
          Keep track of the Last row inserted into the DTM from the ResultSet.
private  int m_MetaData_TypeID
           
private  int m_MetaDataIdx
          The Index of the MetaData Node.
private  ResultSet m_ResultSet
          The conduit to our data that will be used to fill the document.
private  int m_Row_TypeID
           
private  int m_RowSet_TypeID
           
private  int m_RowSetIdx
          The index of the Row Set node.
private  int m_SQL_TypeID
           
private  int m_SQLIdx
           
private  Statement m_Statement
          The Statement used to extract the data from the Database connection.
private  boolean m_StreamingMode
          Streaming Mode Control, In Streaming mode we reduce the memory footprint since we only use a single row instance.
private static String S_CASESENSITIVE
           
private static String S_CATALOGUE_NAME
           
private static String S_COL
           
private static String S_COLUMN_HEADER
           
private static String S_COLUMN_LABEL
           
private static String S_COLUMN_NAME
           
private static String S_COLUMN_TYPE
           
private static String S_COLUMN_TYPENAME
           
private static String S_DEFINITLEYWRITABLE
           
private static String S_DISPLAY_SIZE
           
private static String S_ISNULLABLE
           
private static String S_ISSEARCHABLE
           
private static String S_ISSIGNED
           
private static String S_ISWRITEABLE
           
private static String S_METADATA
           
private static String S_NAMESPACE
           
private static String S_PRECISION
           
private static String S_ROW
           
private static String S_ROW_SET
           
private static String S_SCALE
           
private static String S_SCHEMA_NAME
           
private static String S_SQL
           
private static String S_TABLE_NAME
           
 
Fields inherited from class org.apache.xalan.lib.sql.DTMDocument
m_attribute, m_Document_TypeID, m_DocumentIdx, m_ObjectArray, m_TextNode_TypeID, S_ATTRIB_NOT_SUPPORTED, S_DOCUMENT, S_ELEMENT_NODE, S_ISFALSE, S_ISTRUE, S_TEXT_NODE
 
Fields inherited from class org.apache.xml.dtm.ref.DTMDefaultBase
m_blocksize, m_documentBaseURI, m_dtmIdent, m_elemIndexes, m_expandedNameTable, m_exptype, m_firstch, m_indexing, m_initialblocksize, m_mgr, m_mgrDefault, m_namespaceDeclSetElements, m_namespaceDeclSets, m_nextsib, m_parent, m_prevsib, m_shouldStripWhitespaceStack, m_shouldStripWS, m_size, m_traversers, m_wsfilter, m_xstrf, NOTPROCESSED
 
Fields inherited from interface org.apache.xml.dtm.DTM
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NAMESPACE_NODE, NOTATION_NODE, NTYPES, NULL, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
SQLDocument(DTMManager mgr, int ident, ConnectionPool pool, Connection con, Statement stmt, ResultSet data, boolean streamingMode)
           
 
Method Summary
protected  int _nextsib(int identity)
          Get the next sibling for the given node identity.
private  boolean addRowToDTMFromResultSet()
          Pull a record from the result set and map it to a DTM based ROW If we are in Streaming mode, then only create a single row and keep copying the data into the same row.
 void close()
          Clean up our ties to the database but this does not necessarly clean up the document.
 void closeOnError()
          When an error occurs, the XConnection will call this method do that we can deal with the Connection properly
protected  void createExpandedNameTable()
          Populate the Expanded Name Table with the Node that we will use.
 void documentRegistration()
          A dummy routine to satisify the abstract interface.
 void documentRelease()
          A dummy routine to satisify the abstract interface.
private  void extractSQLMetaData(ResultSetMetaData meta)
          Extract the Meta Data and build the Column Attribute List.
protected  boolean nextNode()
          This method should try and build one or more nodes in the table.
 
Methods inherited from class org.apache.xalan.lib.sql.DTMDocument
_exptype, _firstch, _level, _parent, _prevsib, _type, addAttributeToNode, addElement, addElementWithData, appendChild, appendTextChild, cloneAttributeFromNode, declareNamespaceInContext, dispatchCharactersEvents, dispatchNodeData, dispatchToEvents, dumpDTM, ensureSize, ensureSizeOfIndex, error, findGTE, findInSortedSuballocatedIntVector, findNamespaceContext, getAttributeNode, getAxisIterator, getAxisTraverser, getContentHandler, getDeclHandler, getDocument, getDocumentAllDeclarationsProcessed, getDocumentBaseURI, getDocumentEncoding, getDocumentStandalone, getDocumentSystemIdentifier, getDocumentTypeDeclarationPublicIdentifier, getDocumentTypeDeclarationSystemIdentifier, getDocumentVersion, getDTDHandler, getElementById, getEntityResolver, getErrorHandler, getExpandedTypeID, getExpandedTypeID, getFirstAttribute, getFirstChild, getFirstNamespaceNode, getLastChild, getLevel, getLexicalHandler, getLocalName, getLocalNameFromExpandedNameID, getNamespaceFromExpandedNameID, getNamespaceType, getNamespaceURI, getNextAttribute, getNextNamespaceNode, getNextNodeIdentity, getNextSibling, getNode, getNodeName, getNodeNameX, getNodeType, getNodeValue, getNumberOfNodes, getOwnerDocument, getParent, getPrefix, getPreviousSibling, getShouldStripWhitespace, getSourceLocatorFor, getStringValue, getStringValueChunk, getStringValueChunkCount, getTypedAxisIterator, getUnparsedEntityURI, hasChildNodes, indexNode, isAttributeSpecified, isCharacterElementContentWhitespace, isDocumentAllDeclarationsProcessed, isNodeAfter, isSupported, needsTwoThreads, popShouldStripWhitespace, pushShouldStripWhitespace, setDocumentBaseURI, setFeature, setProperty, setShouldStripWhitespace, supportsPreStripping
 
Methods inherited from class org.apache.xml.dtm.ref.DTMDefaultBase
dumpDTM, dumpNode, getDocumentRoot, getDTMIDs, getManager, makeNodeHandle, makeNodeIdentity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private boolean DEBUG

S_NAMESPACE

private static final String S_NAMESPACE
See Also:
Constant Field Values

S_SQL

private static final String S_SQL
See Also:
Constant Field Values

S_ROW_SET

private static final String S_ROW_SET
See Also:
Constant Field Values

S_METADATA

private static final String S_METADATA
See Also:
Constant Field Values

S_COLUMN_HEADER

private static final String S_COLUMN_HEADER
See Also:
Constant Field Values

S_ROW

private static final String S_ROW
See Also:
Constant Field Values

S_COL

private static final String S_COL
See Also:
Constant Field Values

S_CATALOGUE_NAME

private static final String S_CATALOGUE_NAME
See Also:
Constant Field Values

S_DISPLAY_SIZE

private static final String S_DISPLAY_SIZE
See Also:
Constant Field Values

S_COLUMN_LABEL

private static final String S_COLUMN_LABEL
See Also:
Constant Field Values

S_COLUMN_NAME

private static final String S_COLUMN_NAME
See Also:
Constant Field Values

S_COLUMN_TYPE

private static final String S_COLUMN_TYPE
See Also:
Constant Field Values

S_COLUMN_TYPENAME

private static final String S_COLUMN_TYPENAME
See Also:
Constant Field Values

S_PRECISION

private static final String S_PRECISION
See Also:
Constant Field Values

S_SCALE

private static final String S_SCALE
See Also:
Constant Field Values

S_SCHEMA_NAME

private static final String S_SCHEMA_NAME
See Also:
Constant Field Values

S_TABLE_NAME

private static final String S_TABLE_NAME
See Also:
Constant Field Values

S_CASESENSITIVE

private static final String S_CASESENSITIVE
See Also:
Constant Field Values

S_DEFINITLEYWRITABLE

private static final String S_DEFINITLEYWRITABLE
See Also:
Constant Field Values

S_ISNULLABLE

private static final String S_ISNULLABLE
See Also:
Constant Field Values

S_ISSIGNED

private static final String S_ISSIGNED
See Also:
Constant Field Values

S_ISWRITEABLE

private static final String S_ISWRITEABLE
See Also:
Constant Field Values

S_ISSEARCHABLE

private static final String S_ISSEARCHABLE
See Also:
Constant Field Values

m_SQL_TypeID

private int m_SQL_TypeID

m_MetaData_TypeID

private int m_MetaData_TypeID

m_ColumnHeader_TypeID

private int m_ColumnHeader_TypeID

m_RowSet_TypeID

private int m_RowSet_TypeID

m_Row_TypeID

private int m_Row_TypeID

m_Col_TypeID

private int m_Col_TypeID

m_ColAttrib_CATALOGUE_NAME_TypeID

private int m_ColAttrib_CATALOGUE_NAME_TypeID

m_ColAttrib_DISPLAY_SIZE_TypeID

private int m_ColAttrib_DISPLAY_SIZE_TypeID

m_ColAttrib_COLUMN_LABEL_TypeID

private int m_ColAttrib_COLUMN_LABEL_TypeID

m_ColAttrib_COLUMN_NAME_TypeID

private int m_ColAttrib_COLUMN_NAME_TypeID

m_ColAttrib_COLUMN_TYPE_TypeID

private int m_ColAttrib_COLUMN_TYPE_TypeID

m_ColAttrib_COLUMN_TYPENAME_TypeID

private int m_ColAttrib_COLUMN_TYPENAME_TypeID

m_ColAttrib_PRECISION_TypeID

private int m_ColAttrib_PRECISION_TypeID

m_ColAttrib_SCALE_TypeID

private int m_ColAttrib_SCALE_TypeID

m_ColAttrib_SCHEMA_NAME_TypeID

private int m_ColAttrib_SCHEMA_NAME_TypeID

m_ColAttrib_TABLE_NAME_TypeID

private int m_ColAttrib_TABLE_NAME_TypeID

m_ColAttrib_CASESENSITIVE_TypeID

private int m_ColAttrib_CASESENSITIVE_TypeID

m_ColAttrib_DEFINITLEYWRITEABLE_TypeID

private int m_ColAttrib_DEFINITLEYWRITEABLE_TypeID

m_ColAttrib_ISNULLABLE_TypeID

private int m_ColAttrib_ISNULLABLE_TypeID

m_ColAttrib_ISSIGNED_TypeID

private int m_ColAttrib_ISSIGNED_TypeID

m_ColAttrib_ISWRITEABLE_TypeID

private int m_ColAttrib_ISWRITEABLE_TypeID

m_ColAttrib_ISSEARCHABLE_TypeID

private int m_ColAttrib_ISSEARCHABLE_TypeID

m_Connection

private Connection m_Connection
The DBMS Connection used to produce this SQL Document. Will be used to clear free up the database resources on close.


m_Statement

private Statement m_Statement
The Statement used to extract the data from the Database connection. We really don't need the connection, but it is NOT defined from JDBC Driver to driver what happens to the ResultSet if the statment is closed prior to reading all the data needed. So as long as we are using the ResultSet, we will track the Statement used to produce it.


m_ResultSet

private ResultSet m_ResultSet
The conduit to our data that will be used to fill the document.


m_ConnectionPool

private ConnectionPool m_ConnectionPool
The Connection Pool that originally produced the connection.


m_ColHeadersIdx

private int[] m_ColHeadersIdx
As the column header array is built, keep the node index for each Column. The primary use of this is to locate the first attribute for each column in each row as we add records.


m_ColCount

private int m_ColCount
An indicator on how many columns are in this query


m_MetaDataIdx

private int m_MetaDataIdx
The Index of the MetaData Node. Currently the MetaData Node contains the


m_RowSetIdx

private int m_RowSetIdx
The index of the Row Set node. This is the sibling directly after the last Column Header.


m_SQLIdx

private int m_SQLIdx

m_FirstRowIdx

private int m_FirstRowIdx
Demark the first row element where we started adding rows into the Document.


m_LastRowIdx

private int m_LastRowIdx
Keep track of the Last row inserted into the DTM from the ResultSet. This will be used as the index of the parent Row Element when adding a row.


m_StreamingMode

private boolean m_StreamingMode
Streaming Mode Control, In Streaming mode we reduce the memory footprint since we only use a single row instance.

Constructor Detail

SQLDocument

public SQLDocument(DTMManager mgr,
                   int ident,
                   ConnectionPool pool,
                   Connection con,
                   Statement stmt,
                   ResultSet data,
                   boolean streamingMode)
            throws SQLException
Parameters:
mgr -
ident -
pool -
con -
stmt -
data -
streamingMode -
Throws:
SQLException
Method Detail

extractSQLMetaData

private void extractSQLMetaData(ResultSetMetaData meta)
Extract the Meta Data and build the Column Attribute List.

Parameters:
meta -
Returns:

createExpandedNameTable

protected void createExpandedNameTable()
Populate the Expanded Name Table with the Node that we will use. Keep a reference of each of the types for access speed.

Overrides:
createExpandedNameTable in class DTMDocument
Returns:

addRowToDTMFromResultSet

private boolean addRowToDTMFromResultSet()
Pull a record from the result set and map it to a DTM based ROW If we are in Streaming mode, then only create a single row and keep copying the data into the same row. This will keep the memory footprint constint independant of the RecordSet Size. If we are not in Streaming mode then create ROWS for the whole tree.

Returns:

close

public void close()
Clean up our ties to the database but this does not necessarly clean up the document.

Returns:

closeOnError

public void closeOnError()
When an error occurs, the XConnection will call this method do that we can deal with the Connection properly

Returns:

nextNode

protected boolean nextNode()
Description copied from class: DTMDefaultBase
This method should try and build one or more nodes in the table.

Overrides:
nextNode in class DTMDocument
Returns:

_nextsib

protected int _nextsib(int identity)
Description copied from class: DTMDefaultBase
Get the next sibling for the given node identity.

Overrides:
_nextsib in class DTMDocument
Parameters:
identity -
Returns:

documentRegistration

public void documentRegistration()
Description copied from class: DTMDefaultBase
A dummy routine to satisify the abstract interface. If the DTM implememtation that extends the default base requires notification of registration, they can override this method.

Specified by:
documentRegistration in interface DTM
Overrides:
documentRegistration in class DTMDefaultBase

documentRelease

public void documentRelease()
Description copied from class: DTMDefaultBase
A dummy routine to satisify the abstract interface. If the DTM implememtation that extends the default base requires notification when the document is being released, they can override this method

Specified by:
documentRelease in interface DTM
Overrides:
documentRelease in class DTMDefaultBase