Hi,

I've encountered a great deal of difficulties using the sql
extension's pquery feature.

Here is the stylesheet:

__STYLESHEET__
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0"
                xmlns:sql="org.apache.xalan.lib.sql.XConnection"
                extension-element-prefixes="sql">

  <xsl:output method="xml" indent="yes"/>
 
  <xsl:variable name="driver" select="'org.gjt.mm.mysql.Driver'" />
  <xsl:variable name="driver-url" select="'jdbc:mysql://shelby/ndc'" />


  <xsl:template match="/">
    <!-- CONNECTION -->
    <xsl:variable name="products"
            select="sql:new($driver, $driver-url)" 
            />

    <drug-listing>
      <xsl:value-of select="sql:addParameterWithType('0000000001', 'string')"/>
      <xsl:variable name="listing" select="sql:pquery($products, 'SELECT * FROM 
listing where listing_seq_no = ?', 'string')"/>
      <xsl:apply-templates select="$listing/sql/row-set"/>
    </drug-listing>
    <xsl:value-of select="sql:close($products)"/>
  </xsl:template>

  <xsl:template match="row">
    <drug>
      <xsl:variable name="drug-seq-no">
        <xsl:value-of select="col[1]"/>
      </xsl:variable>
      <xsl:attribute name="seq-no">
        <xsl:value-of select="col[1]"/>
      </xsl:attribute>
      <name>
        <xsl:value-of select="col[9]"/>
      </name>
    </drug>
  </xsl:template>
</xsl:stylesheet>
__END_STYLESHEET__

I've been using the debugging feature of XConnection and here is
the above stylesheet's output:

__OUTPUT__
XConnection, Connection Init
XConnection, Creating Connection
 Driver  :org.gjt.mm.mysql.Driver
 URL     :jdbc:mysql://shelby/ndc
 user    :
 passwd  :
<?xml version="1.0" encoding="UTF-8"?>
Adding parameterWithType: 0000000001:string
qp: v == 0000000001; t == string
Note: m_ParameterList's size now == 1
And it's hashCode == 246585228
And my hashCode == 246584961
Entered pquery(3)...
adding another token [0] ...
value of this token == string
Note: size of m_ParameterList == 0
And it's hashValue == 1 [really is hashCode -ed]
And my hashCode == 246550053
Error: java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
<drug-listing/>Entering XConnection.close
Exiting XConnection.close
__END_OUTPUT__

As you can see, when it goes into pquery, it finds that
m_ParameterList's size is 0 as where, when adding the parameter, it
was 1 (which it should be). 

Any ideas on this? From reading the source code, it seems there should
be one and only one m_ParameterList, and yet when it is referenced in
pquery it looks like it's a brand new m_ParameterList.

Any ideas?

Thank you, Elizabeth

Reply via email to