You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Jinhua Fan <jf...@ohpp.com> on 2003/01/27 21:16:52 UTC

Xalan SQL Extension DB Connection Question

I am new to XALAN SQL Extension.  I read about the SQL extension and want to
try it is a style sheet. 

I got "Invalid Driver Name Specified!" error message when try to query the
db.  Could any one help me to identify where the problem is. The DbUser and
password are both fine.

Thank you.

****************************************************************************
********

The following is the snippet of the style sheet that I used.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:java="http://xml.apache.org/xslt/java"
		version="1.0"
		xmlns:sql="org.apache.xalan.lib.sql.XConnection"  
		extension-element-prefixes="sql">
		
    <xsl:output method="xml" indent="yes"/>
    
    <xsl:param name="driver" select="'oracle.jdbc.driver.OracleDriver'"/>
    <xsl:param name="dbUrl"
select="'jdbc:oracle:thin:@servername:####:instanceName'"/>
  
    
    <!-- define a query --> 
    <xsl:param name="pquery" select="'SELECT * FROM mytable '"/>



    <xsl:template match="/">
        <!-- connect to db -->
        <xsl:variable name = "dbobj" select = "sql:new($driver, $dbUrl,
'userName', 'password')" />
                                   
        <xsl:element name="ROWSET">
                ... ...
                 
            <xsl:for-each select="/DataSet/DataRow" >

		... ...
	        
                <!-- query the data -->
                <xsl:variable name="resultSet" select='sql:query($dbobj,
$pquery )'/>
          
                <!-- Error Checking, it is stored in the connection since
$resultSet will be either data or null -->
                <xsl:if test="not($resultSet)" >
          	    <xsl:message >Error in query</xsl:message>
                    <xsl:copy-of select="sql:getError($dbobj)/ext-error" />
                </xsl:if>

            </xsl:for-each>
        </xsl:element>
        
        <!-- Close the connection -->
        <xsl:value-of select="sql:close($dbobj)"/>           
    </xsl:template>
</xsl:stylesheet>