You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-user@db.apache.org by Jun Li <al...@gmail.com> on 2006/03/01 01:37:42 UTC

Re: How can I write data within a list of tables into a XML file?

How did you get the SqlDynaBean iterator?

I see from the platform.query() or platform.fetch(), we can only get normal
dyna beans.

How could you convert them to SqlDynaBeans?

Thx in advance.

On 2/24/06, Vignesh Swaminathan <vs...@cordys.com> wrote:
>
> >How can I do this in Java program?
> >To export data from a list of tables into a XML file, which
> class.methodshould I use?
>
> I have came across this but not really tried it out full extent,
>
> org.apache.ddlutils.io.DataWriter
>
> DataWriter dataWriter = new DataWriter(System.out); //any output stream
> dataWriter.write(iter); // a SqlDynaBean iterator (will not work for
> normal dyna beans);
>
> <vignesh/>
> "Winning solutions find the right balance between market needs and
> technical needs"
>
>
>
> ***************************************************************************************************
> The information in this message is confidential and may be
> legally  privileged.
> It is intended solely for the addressee. Access to this message by anyone
> else is
> unauthorized. If you are not the intended recipient, any disclosure,
> copying, or
> distribution of the message, or any action or omission taken by you in
> reliance
> on it is prohibited and may be unlawful. Please immediately contact the
> sender if
> you have received this message in error. This email does not constitute
> any
> commitment  from Cordys Holding BV or any of its subsidiaries except when
> expressly agreed in a written agreement between the intended recipient and
>
> Cordys Holding BV or its subsidiaries.
>
> ***************************************************************************************************
>
>


--
--------------
Cheers,
Jun

Re: How can I write data within a list of tables into a XML file?

Posted by Jun Li <al...@gmail.com>.
I see, the DataToDatabaseSink does work on live DB.

But another problem is, if the data with the same PK value already exists in
DB, can the DdlUtils just update the data instead of getting exception of
violation of PK.

On 4/10/06, Jun Li <al...@gmail.com> wrote:
>
>
>
>  On 3/1/06, Thomas Dudziak <to...@gmail.com> wrote:
>
> > On 3/1/06, Jun Li <al...@gmail.com> wrote:
> >
> > > Here comes another question, how can I use DataReader to read the XML
> > file
> > > in and then insert them back to a database?
> >
> > This is similar, you'll just need the DataToDatabaseSink. E.g. have a
> > look at the WriteDataToDatabaseCommand :
> >
> >
> > http://svn.apache.org/viewcvs.cgi/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java?view=markup
> >
> > Tom
> >
>
> I mean write data into a live database not a model.
> I guess I'll need to use *platform.* *insert*( Database model, Collection<http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html>
>  dynaBeans).
>
> But how to read the data from xml in to dynaBeans?
>
> --------------
> Cheers,
> Jun
>



--
--------------
Cheers,
Jun

Re: How can I write data within a list of tables into a XML file?

Posted by Jun Li <al...@gmail.com>.
On 3/1/06, Thomas Dudziak <to...@gmail.com> wrote:
>
> On 3/1/06, Jun Li <al...@gmail.com> wrote:
>
> > Here comes another question, how can I use DataReader to read the XML
> file
> > in and then insert them back to a database?
>
> This is similar, you'll just need the DataToDatabaseSink. E.g. have a
> look at the WriteDataToDatabaseCommand :
>
>
> http://svn.apache.org/viewcvs.cgi/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java?view=markup
>
> Tom
>

I mean write data into a live database not a model.
I guess I'll need to use
*platform.**insert*<file:///D:/workspace/DdlUtils-1.0/doc/api/org/apache/ddlutils/Platform.html#insert(org.apache.ddlutils.model.Database,
java.util.Collection)>(Database<file:///D:/workspace/DdlUtils-1.0/doc/api/org/apache/ddlutils/model/Database.html>
model,
Collection<http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html>
 dynaBeans).

But how to read the data from xml in to dynaBeans?

--------------
Cheers,
Jun

Re: How can I write data within a list of tables into a XML file?

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/1/06, Jun Li <al...@gmail.com> wrote:

> Here comes another question, how can I use DataReader to read the XML file
> in and then insert them back to a database?

This is similar, you'll just need the DataToDatabaseSink. E.g. have a
look at the WriteDataToDatabaseCommand :

http://svn.apache.org/viewcvs.cgi/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java?view=markup

Tom

Re: How can I write data within a list of tables into a XML file?

Posted by Jun Li <al...@gmail.com>.
Thanks for the instruction. It now works beautifully.

Here comes another question, how can I use DataReader to read the XML file
in and then insert them back to a database?


On 3/1/06, Thomas Dudziak <to...@gmail.com> wrote:
>
>
> You should give the table hints to the query method. See also the
> WriteDataToFileCommand class which does exactly this:
>
>
> http://svn.apache.org/viewcvs.cgi/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToFileCommand.java?view=markup
>
> Tom
>



--
--------------
Cheers,
Jun

Re: How can I write data within a list of tables into a XML file?

Posted by Thomas Dudziak <to...@gmail.com>.
On 3/1/06, Jun Li <al...@gmail.com> wrote:

> How did you get the SqlDynaBean iterator?

You get SqlDynaBean instances automatically when DdlUtils can
determine the table that corresponds to your query.

> I see from the platform.query() or platform.fetch(), we can only get normal
> dyna beans.
>
> How could you convert them to SqlDynaBeans?

You should give the table hints to the query method. See also the
WriteDataToFileCommand class which does exactly this:

http://svn.apache.org/viewcvs.cgi/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToFileCommand.java?view=markup

Tom