xmlBlaster 2.1.0 API

org.xmlBlaster.protocol.jdbc
Class XmlDBAdapter

java.lang.Object
  extended by org.xmlBlaster.protocol.jdbc.XmlDBAdapter

public class XmlDBAdapter
extends java.lang.Object

For every database access, an instance of this class does the work in a dedicated thread.


Field Summary
private  byte[] content
           
private  Global glob
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  NamedConnectionPool namedPool
           
 
Constructor Summary
XmlDBAdapter(Global glob, byte[] content, NamedConnectionPool namedPool)
          Create the worker instance to handle a single RDBMS request.
 
Method Summary
private  org.w3c.dom.Document createDocument()
          Parse the XML encoded SQL statement.
private  org.w3c.dom.Document createEmptyDocument()
           
private  org.w3c.dom.Document createUpdateDocument(int rowsAffected, ConnectionDescriptor descriptor)
           
private  MsgUnit[] getResponseMessage(byte[] content, java.lang.String contentMimeExtended)
          Create the result/exception/return message.
private  MsgUnit[] getResponseMessage(org.w3c.dom.Document doc)
          SELECT results in XML.
 MsgUnit[] query()
          Query the database.
private  org.w3c.dom.Document queryDB(ConnectionDescriptor descriptor)
          Query the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

glob

private final Global glob

log

private static java.util.logging.Logger log

content

private byte[] content

namedPool

private NamedConnectionPool namedPool
Constructor Detail

XmlDBAdapter

public XmlDBAdapter(Global glob,
                    byte[] content,
                    NamedConnectionPool namedPool)
Create the worker instance to handle a single RDBMS request.

Parameters:
content - The SQL statement
namedPool - A pool of JDBC connections for the RDBMS users
Method Detail

query

public MsgUnit[] query()
Query the database.

INSERT, UPDATE, CREATE results look like this (content variable):

<?xml version="1.0" encoding="UTF-8"?>
<dbadapterresults>
     <row>
        1 row(s) were affected during the update.
     </row>
</dbadapterresults>
 
SELECT results look like this:
<?xml version="1.0" encoding="UTF-8"?>
<dbadapterresults>
  <desc>
     <numcolumns>2</numcolumns>
     <columnnames>
        <column>NAME</column>
        <column>AGE</column>
     </columnnames>
     <rownum>2</rownum>
  </desc>
  <results>
     <row>
        <NAME>
        Ben
        </NAME>
        <AGE>
        6
        </AGE>
     </row>
     <row>
        <NAME>
        Tim
        </NAME>
        <AGE>
        8
        </AGE>
     </row>
  </results>
</dbadapterresults>
 
Exceptions like this:
   <exception id='" + id + "'>
      <class>JavaClass</class>
      <reason><![cdata[
        bla bla
      ]]></reason>
   </exception>
 

Returns:
One MsgUnitRaw with the content as described above.

createDocument

private org.w3c.dom.Document createDocument()
                                     throws java.lang.Exception
Parse the XML encoded SQL statement.

Throws:
java.lang.Exception

queryDB

private org.w3c.dom.Document queryDB(ConnectionDescriptor descriptor)
                              throws XmlBlasterException
Query the database.

Throws:
XmlBlasterException

createEmptyDocument

private org.w3c.dom.Document createEmptyDocument()
                                          throws XmlBlasterException
Parameters:
rowsAffected -
descriptor -
Throws:
XmlBlasterException

createUpdateDocument

private org.w3c.dom.Document createUpdateDocument(int rowsAffected,
                                                  ConnectionDescriptor descriptor)
                                           throws XmlBlasterException
Parameters:
rowsAffected -
descriptor -
Throws:
XmlBlasterException

getResponseMessage

private MsgUnit[] getResponseMessage(org.w3c.dom.Document doc)
SELECT results in XML.


getResponseMessage

private MsgUnit[] getResponseMessage(byte[] content,
                                     java.lang.String contentMimeExtended)
Create the result/exception/return message.

Note that the Publish...Wrapper are for get() and update() identical

Parameters:
content -
contentMimeExtended - Informative only, "XmlBlasterException" or "QueryResults"

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.