cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Mallmann" <jim.mallm...@topicalnetworks.com>
Subject Problem using esql:get-int
Date Fri, 02 Feb 2001 20:35:20 GMT
Hi, all.

I'm having a inserting some info into my DB, and I appear to have it
narrowed down to my use of the <esql:get-int> tag.  The problem is not
necessarily the tag itself, but it might have something to do with how I'm
using it and how it's nested.

I have three queries marked in the code at the bottom of this message.  The
first retrieves an artistID, and the second retrieves a genreID.  The third
query needs to use both of these numbers for its own insertion.

In the section I have labeled "Messages for Debugging" I have two messages
that I bring to the screen for debugging my problem.  These messages print
the queries as they should appear.

But when I use the same syntax in the third query I get the following error
for the first query above,
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------
SYNTAX:

insert into digital_music (productID, genreID) values (<esql:parameter
type="string"><xsp:expr>new String("<xsl:value-of
select="PRODUCT_DETAILS/@PRODUCT_ID"/>")</xsp:expr></esql:parameter>,<esql:p
arameter type="int"><esql:get-int column="genreID"/></esql:parameter>)

ERROR:
java.lang.RuntimeException: Error setting parameter on statement:
insert into digital_music (productID, genreID) values (?,?)
	at
_C_._Java._jakarta_tomcat_3_2_1._webapps._cocoon._tn._iontunes._bmgcatalogsa
mplefullplay.populateDocument(_bmgcatalogsamplefullplay.java:621)
	at org.apache.cocoon.processor.xsp.XSPPage.getDocument(XSPPage.java:97)
	at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:524)
	at org.apache.cocoon.Engine.handle(Engine.java:383)
	at org.apache.cocoon.Cocoon.service(Cocoon.java:183)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
	at org.apache.tomcat.core.Handler.service(Handler.java:286)
	at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
	at java.lang.Thread.run(Thread.java:484)
_bmgcatalogsamplefullplay.java

615            try {
616
_esql_query.prepared_statement.setInt(2,((EsqlQuery)_esql_queries.elementAt(
_esql_queries.size()-1)).resultset.getInt("artistID"));
617
618
619
620            } catch (SQLException _esql_exception_N11340) {
621              throw new RuntimeException("Error setting parameter on
statement: "+_esql_query.query);
622            }

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------

and the following error for the second query

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------
SYNTAX:

insert into digital_music (productID, genreID) values (<esql:parameter
type="string"><xsp:expr>new String("<xsl:value-of
select="PRODUCT_DETAILS/@PRODUCT_ID"/>")</xsp:expr></esql:parameter>,<esql:p
arameter type="int"><esql:get-int column="genreID"/></esql:parameter>)

Error:
java.lang.NullPointerException
	at
_C_._Java._jakarta_tomcat_3_2_1._webapps._cocoon._tn._iontunes._bmgcatalogsa
mplefullplay.populateDocument(_bmgcatalogsamplefullplay.java:616)
	at org.apache.cocoon.processor.xsp.XSPPage.getDocument(XSPPage.java:97)
	at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:524)
	at org.apache.cocoon.Engine.handle(Engine.java:383)
	at org.apache.cocoon.Cocoon.service(Cocoon.java:183)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
	at org.apache.tomcat.core.Handler.service(Handler.java:286)
	at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
	at java.lang.Thread.run(Thread.java:484)

_bmgcatalogsamplefullplay.java

615            try {
616
_esql_query.prepared_statement.setInt(2,_esql_query.resultset.getInt("genreI
D"));
617
618
619
620            } catch (SQLException _esql_exception_N217e57) {
621              throw new RuntimeException("Error setting parameter on
statement: "+_esql_query.query);
622            }

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------

I thought that this might be a problem with using or not using the ancestor
attribute, but I've played around with it a little bit without success.

Any help I can get on this problem would be greatly appreciated.

Jim

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------
Code:

<esql:connection>
    <esql:driver>sun.jdbc.odbc.JdbcOdbcDriver</esql:driver>
    <esql:dburl>jdbc:odbc:LocalServer</esql:dburl>
    <esql:username>sa</esql:username>
    <esql:password>T0pneT</esql:password>
    <esql:execute-query>
    <esql:query>   <!-- ------------- FIRST QUERY ------------- -->
        select artistID from artist where artist_display_name =
'<xsl:value-of select="PRODUCT_DETAILS/@PRODUCT_ARTIST_DISPLAY_NAME"/>'
    </esql:query>
    <esql:results>
        <esql:row-results>
            <esql:connection>
                <esql:driver>sun.jdbc.odbc.JdbcOdbcDriver</esql:driver>
                <esql:dburl>jdbc:odbc:LocalServer</esql:dburl>
                <esql:username>sa</esql:username>
                <esql:password>T0pneT</esql:password>
                <esql:execute-query>
                    <esql:query>    <!-- ------------- SECOND
QUERY ------------- -->
                        select genreID from genre where genrename =
<esql:parameter type="string"><xsp:expr>new String("<xsl:value-of
select="PRODUCT_DETAILS/@GENRE_TYPE"/>")</xsp:expr></esql:parameter>
                    </esql:query>
                    <esql:results>
                        <esql:row-results>
                            <!-- ------------- MESSAGES FOR
DEBUGGING ------------- -->
                            <message>insert into digital_music (productID,
artistID) values (<esql:parameter type="string"><xsp:expr>new
String("<xsl:value-of
select="PRODUCT_DETAILS/@PRODUCT_ID"/>")</xsp:expr></esql:parameter>,<esql:p
arameter type="int"><esql:get-int ancestor="1"
column="artistID"/></esql:parameter>)
                            </message>
                            <message>insert into digital_music (productID,
genreID) values (<esql:parameter type="string"><xsp:expr>new
String("<xsl:value-of
select="PRODUCT_DETAILS/@PRODUCT_ID"/>")</xsp:expr></esql:parameter>,<esql:p
arameter type="int"><esql:get-int column="genreID"/></esql:parameter>)
                            </message>
                            <esql:connection>

<esql:driver>sun.jdbc.odbc.JdbcOdbcDriver</esql:driver>

<esql:dburl>jdbc:odbc:LocalServer</esql:dburl>
                                <esql:username>sa</esql:username>
                                <esql:password>T0pneT</esql:password>
                                <esql:execute-query>
                                    <esql:query>    <!-- ------------- THIRD
QUERY ------------- -->
                                            insert into digital_music
(productID, genreID) values (<esql:parameter type="string"><xsp:expr>new
String("<xsl:value-of
select="PRODUCT_DETAILS/@PRODUCT_ID"/>")</xsp:expr></esql:parameter>,<esql:p
arameter type="int"><esql:get-int column="genreID"/></esql:parameter>)
                                    </esql:query>
                                    <esql:error-results>
                                        <message>Insert product to
digital_music attempt: <esql:get-message/></message>

<stacktrace><esql:get-stacktrace/></stacktrace>
                                    </esql:error-results>
                                </esql:execute-query>
                            </esql:connection>
                        </esql:row-results>
                    </esql:results>
                </esql:execute-query>
            </esql:connection>
        </esql:row-results>
    </esql:results>




Mime
View raw message