You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Brendan Corcoran <br...@jenisys.com.au> on 2001/02/01 05:39:35 UTC

esql including java.sql.ResultSet

Hello,

I am trying to insert dynamic xml.  I have a JavaBean that returns a
java.sql.ResultSet to my xsp page, and I then pass this into the XMLFragment
interface that generates SAX events so that I can include the ResultSet as
xml in my document.

Is it possible to plug the ResultSet from the JavaBean into the esql taglib
to include the ResultSet as xml in my document, and to do further
processing?  This is instead of going through the XMLFragment interface..

What are the pros/cons of each method?  Any other alternatives?

thanks,

Brendan


Re: esql including java.sql.ResultSet

Posted by Brendan Corcoran <br...@jenisys.com.au>.
Hi,

Has anyone got any opinion on the following scenario?  Any
comments/suggestions would be greatly appreciated.

What I've got is a class that implements XMLFragment.   In the toSAX()
method it parses through the ResultSet returned from a JavaBean that queries
a relational db filled with plain (non-xml) data, and generates SAX events
based on the rows and columns of the ResultSet.

The class I have to do this is called XMLResultOutHelper() and it implements
XMLFragment and extends a few JavaBeans.

This class has an xml_root field - this is the xml-tag name that is going to
encapsulate the whole of the included ResultSet.  The class also has an
xml_row field - this is the xml-tag name that will encapsulate each row of
the ResultSet

So when I include the toSAX() method in my xsp, the resulting xml is
something like:

<db_members_query>
    <member>
        <elem name="member_id">1</elem>
        <elem name="member_surname">Bloggs</elem>
    </member>
    <member>
        <elem name="member_id">2</elem>
        <elem name="member_surname">Braggs</elem>
    </member>
</db_members_query>

I was wondering if this was the cleanest, most efficient way to include
information into xsp from a JavaBean that returns a ResultSet from a
database...

Or should I be looking at packaging the ResultSet into an xml String in the
JavaBean and including it from there using <util:include-expr>.....

I know there was a thread a little while back entitled "toDOM and toSAX of
XMLFragment", but I failed to get a grasp on what was actually
resolved...... ie. the one with the timestamp "Wednesday, 24 Jan 2001,
6:09AM" from Ulrich seemed to indicate that the above method wasn't ideal

thanks,

Brendan


>
> ----- Original Message -----
> From: "Donald Ball" <ba...@webslingerZ.com>
> To: <co...@xml.apache.org>
> Sent: Thursday, February 01, 2001 2:46 PM
> Subject: Re: esql including java.sql.ResultSet
>
>
> > On Thu, 1 Feb 2001, Brendan Corcoran wrote:
> >
> > > I am trying to insert dynamic xml.  I have a JavaBean that returns a
> > > java.sql.ResultSet to my xsp page, and I then pass this into the
> XMLFragment
> > > interface that generates SAX events so that I can include the
ResultSet
> as
> > > xml in my document.
> > >
> > > Is it possible to plug the ResultSet from the JavaBean into the esql
> taglib
> > > to include the ResultSet as xml in my document, and to do further
> > > processing?  This is instead of going through the XMLFragment
> interface..
> >
> > not really, no. the esql logicsheet's methods must operate in context to
> > work. if you were to duplicate the support environment created by the
esql
> > logicsheet, you'd be able to use the access methods, but why bother? the
> > access methods are just wrappers for methods on the JDBC ResultSet and
> > ResultSetMetaData classes, there's little value-add there. the nice
thing
> > about esql, imho, is that it does all of the low-level stuff for you in
a
> > relatively sane way. overall. if you've got a bean of your own that does
> > all of that low-level stuff for you, better just to use it, i'd think.
if
> > you want the get-xml code, look in the source and copy it, or see if you
> > can use the methods in the util logicsheet to include your xml. or am i
> > missing something? Are you having trouble using your resultset's data in
> > calls to other logicsheets?
> >
> > - donald
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>


Re: esql including java.sql.ResultSet

Posted by Brendan Corcoran <br...@jenisys.com.au>.
What I've got is an implementation of XMLFragment that goes through the
ResultSet from the JavaBean, and in to toSAX() method generates SAX events
based on the rows and columns of the ResultSet.

I have defined a class called XMLResultOutHelper() that implements
XMLFragment and extends a few JavaBeans.

Before I include the toSAX() method in my xsp, I set the xml_root field of
XMLResultOutHelper() - this is the tag that is going to encapsulate the
whole of the included ResultSet.  I also set the xml_row field of
XMLResultOutHelper() - this is the tag that will encapsulate each row of the
ResultSet.

So when I include the toSAX() method in my xsp, the resulting xml is
something like:

<db_members_query> - xml_root field
    <member> - xml_row field
        <elem name="member_id">1</elem>
        <elem name="member_surname">Bloggs</elem>
    </member>
    <member>
        <elem name="member_id">2</elem>
        <elem name="member_surname">Braggs</elem>
    </member>
</db_members_query>

I was wondering if this was the cleanest, most efficient way to include
information from a JavaBean that returns a ResultSet from a database....

Or should I be looking at packaging the ResultSet into an xml String in the
JavaBean and including it from there?

thanks,

Brendan

----- Original Message -----
From: "Donald Ball" <ba...@webslingerZ.com>
To: <co...@xml.apache.org>
Sent: Thursday, February 01, 2001 2:46 PM
Subject: Re: esql including java.sql.ResultSet


> On Thu, 1 Feb 2001, Brendan Corcoran wrote:
>
> > I am trying to insert dynamic xml.  I have a JavaBean that returns a
> > java.sql.ResultSet to my xsp page, and I then pass this into the
XMLFragment
> > interface that generates SAX events so that I can include the ResultSet
as
> > xml in my document.
> >
> > Is it possible to plug the ResultSet from the JavaBean into the esql
taglib
> > to include the ResultSet as xml in my document, and to do further
> > processing?  This is instead of going through the XMLFragment
interface..
>
> not really, no. the esql logicsheet's methods must operate in context to
> work. if you were to duplicate the support environment created by the esql
> logicsheet, you'd be able to use the access methods, but why bother? the
> access methods are just wrappers for methods on the JDBC ResultSet and
> ResultSetMetaData classes, there's little value-add there. the nice thing
> about esql, imho, is that it does all of the low-level stuff for you in a
> relatively sane way. overall. if you've got a bean of your own that does
> all of that low-level stuff for you, better just to use it, i'd think. if
> you want the get-xml code, look in the source and copy it, or see if you
> can use the methods in the util logicsheet to include your xml. or am i
> missing something? Are you having trouble using your resultset's data in
> calls to other logicsheets?
>
> - donald
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>


Re: esql including java.sql.ResultSet

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 1 Feb 2001, Brendan Corcoran wrote:

> I am trying to insert dynamic xml.  I have a JavaBean that returns a
> java.sql.ResultSet to my xsp page, and I then pass this into the XMLFragment
> interface that generates SAX events so that I can include the ResultSet as
> xml in my document.
>
> Is it possible to plug the ResultSet from the JavaBean into the esql taglib
> to include the ResultSet as xml in my document, and to do further
> processing?  This is instead of going through the XMLFragment interface..

not really, no. the esql logicsheet's methods must operate in context to
work. if you were to duplicate the support environment created by the esql
logicsheet, you'd be able to use the access methods, but why bother? the
access methods are just wrappers for methods on the JDBC ResultSet and
ResultSetMetaData classes, there's little value-add there. the nice thing
about esql, imho, is that it does all of the low-level stuff for you in a
relatively sane way. overall. if you've got a bean of your own that does
all of that low-level stuff for you, better just to use it, i'd think. if
you want the get-xml code, look in the source and copy it, or see if you
can use the methods in the util logicsheet to include your xml. or am i
missing something? Are you having trouble using your resultset's data in
calls to other logicsheets?

- donald