db-ddlutils-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurent ROCHE <laurent_ro...@yahoo.com>
Subject Still one problem when managing schema ... others fixed !
Date Wed, 14 Nov 2007 15:25:45 GMT

I have made a few fixes to be able to export/import data using schemas (on PostgreSQL), see
files included at the end of the post.
Most of them are quite ugly fixes but that works for me  ... and still, they should not interfere
with other people usage.

I still have one problem though, when running the following code:
        Platform  platform = PlatformFactory.createNewPlatformInstance(dataSource);
        final DatabaseDataIO dataIO = new DatabaseDataIO();
        try {
            FileOutputStream xmlFile = new FileOutputStream(xmlFPN);
            DatabaseIO reader = new DatabaseIO();
            Database model = reader.read(getModelFPN(), XFR_OUT_SCHEMA);
            dataIO.writeDataToXML(platform, model, xmlFile, XML_FILE_ENCODING);
        } catch (IOException e) {
            log.error("Error: Could not create " + xmlFPN);

I get the following errors:
[fims] ERROR [http-80-Processor24]
 Digester.error(1538) | Parse Error at line 2 column 32: Document root element "database",
must match DOCTYPE root "null".
org.xml.sax.SAXParseException: Document root element "database", must match DOCTYPE root "null".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
[fims] ERROR [http-80-Processor24] Digester.error(1538) | Parse Error at line 2 column 32:
Document is invalid: no grammar found.
org.xml.sax.SAXParseException: Document is invalid: no grammar found.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
The file is created OK though ! ? ! ?
 should I do, to get rid of this error messages ?
I understand they come from the parser going through the XML ... but why don't I get these
when using the Ant tasks ?
I must do something wrong somewhere !
Let me know.

Main problem fixed in included files were: 
 - reading a model from XML file (schema is not handled then).
 - INSERT INTO was not prefexing table names with schema name.
 - writeDataToDatabase methods were not handling _determineSchema property.
(neither was writeDataToXML but I fixed that previously - see september post).

I've added a new method in class DatabaseIO:
public Database read(String filename, String schema)
to be able to pass the schema as a parameter.
It's fixed in another way in DdlToDatabaseTask.

If anybody is interested in more
 explanations, feel free to ask.

Moving forward (in next versions), I would assume that it would be better to add the schema
in the XML file produced.
The question is: once in the file (e.g. in the <data> tag)  -that will mean only one
schema per file-, 
or per table (in each line) - that will mean being able to export the complete database with
all schemas.

Once, you get to know it, I find DdlUtils very useful for data migration (as well as DDL migration,
that everybody knows it's very useful ;-) ! ) . The ability to export selected data (tables)
in a selected way (column)  - when using a schema XML file - is fantastic to migrate data
(a shame that's not available on Ant tasks, yet).

I have not finished testing but so far the fixes seem to work OK.
Find included fixes for:
(these are derived from  version 1.0
 files and not the latest SVN files)
(Look for //  LRO fix)
Have fun,
The Computing Froggy


Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 

Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail 
View raw message