You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ddlutils-dev@db.apache.org by Wessam Abd Rabo <we...@gmail.com> on 2007/09/18 14:52:08 UTC

Urgent: MalformedUrlException

Hi,
The following piece of code creates a MalFormedUrl exception. I just read
from an XML file and create a database. This is error Trace:

org.apache.ddlutils.DdlUtilsException: java.net.MalformedURLException
 at org.apache.ddlutils.io.DatabaseIO.read(DatabaseIO.java:172)


This is the only code i write:

 String  nameoffile= "xmltodb.xml";
        Database targetModel = new DatabaseIO().read(nameoffile);

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
        dataSource.setDriverClassName("org.apache.derby.jdbc.ClientDriver");

        boolean    alterDb = false;

        Platform platform = PlatformFactory.createNewPlatformInstance
(dataSource);

        if (alterDb) {
            platform.alterTables(targetModel, false);
        } else {

            platform.createTables(targetModel, true, true);
        }


Thanks in advance

Wessam

Re: Urgent: MalformedUrlException

Posted by Philip Mark Donaghy <pm...@apache.org>.
I ran you code with the File argument read method and I discovered
that you need the ";create=true" at the end of your connection string
if the db does not exist.

Otherwise the mapping.xml and database.dtd are in the DdlUtils.jar.

Philip

On 9/18/07, Wessam Abd Rabo <we...@gmail.com> wrote:
> Thanks for replying.
>
> i used another variant of the read function, the one that takes an
> inputsource, but am not sure that the code i added is sufficient to make it
> work. The exception no longer appears but nothing happens. I assume no
> reading occurs. That's the whole thing.
>
>   String  nameoffile= "H:\\xmltodb.xml";
>         // File xmlfile= new File(nameoffile);
>
> int x;
>
> try {
>     // Declare the file input stream.
>     InputStream fis = new FileInputStream(nameoffile);
>
>     // Read in x from the file.  If not EOF then print x out.
>     while ((x = fis.read())!= -1) {
>         System.out.print(x);
>
>     }
>
>          InputSource insource= new InputSource(fis);
>
>
>         Database targetModel = new DatabaseIO().read(insource);
>
>         BasicDataSource dataSource = new BasicDataSource();
>         dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
>         dataSource.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
>
>         boolean    alterDb = false;
>
>         Platform platform = PlatformFactory.createNewPlatformInstance
> (dataSource);
>
>         if (alterDb) {
>             platform.alterTables(targetModel, false);
>         } else {
>
>             platform.createTables(targetModel, true, true);
>         }
> } catch (Exception e) {
>     System.out.print(e.getMessage());
> }
>
> i found someone else on this alias who had the same problem
> (MalFormedURLException). You see, the problem is that when i run this code
> in netbeans java application it works, but as i include it inside a module,
> it gives this exception. That other guy i guess had a similar problem in
> eclipse. he said that he tired everything, including using other variants of
> the read method but the problem didn't go away except when he included
> database.dtd and mapping.xml files in ddluitls.jar. Can this be relevant
> too? and if that's the case, how can i find these files?
>
> Thanks in advance
>
> Wessam
>
>
>
> On 9/18/07, Thomas Dudziak <to...@gmail.com> wrote:
> >
> > On 9/18/07, Wessam Abd Rabo <we...@gmail.com> wrote:
> >
> > > The following piece of code creates a MalFormedUrl exception. I just
> > read
> > > from an XML file and create a database. This is error Trace:
> > >
> > > org.apache.ddlutils.DdlUtilsException: java.net.MalformedURLException
> > >  at org.apache.ddlutils.io.DatabaseIO.read(DatabaseIO.java:172)
> > >
> > >
> > > This is the only code i write:
> > >
> > >  String  nameoffile= "xmltodb.xml";
> > >         Database targetModel = new DatabaseIO().read(nameoffile);
> > >
> > >         BasicDataSource dataSource = new BasicDataSource();
> > >         dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
> > >         dataSource.setDriverClassName("
> > org.apache.derby.jdbc.ClientDriver ");
> > >
> > >         boolean    alterDb = false;
> > >
> > >         Platform platform = PlatformFactory.createNewPlatformInstance
> > > (dataSource);
> > >
> > >         if (alterDb) {
> > >             platform.alterTables(targetModel, false);
> > >         } else {
> > >
> > >             platform.createTables(targetModel, true, true);
> > >         }
> >
> > Try a different variant of the read method with e.g. a FileInputStream
> > that you opened for the xmltodb.xml file.
> >
> > Tom
> >
>


-- 
Philip Donaghy
Cushing Technologies
Portals.Apache.Org Project
Skype: philipmarkdonaghy
Office: +33 5 56 60 88 02
Mobile: +33 6 20 83 22 62

Re: Urgent: MalformedUrlException

Posted by Wessam Abd Rabo <we...@gmail.com>.
Thanks for replying.

i used another variant of the read function, the one that takes an
inputsource, but am not sure that the code i added is sufficient to make it
work. The exception no longer appears but nothing happens. I assume no
reading occurs. That's the whole thing.

  String  nameoffile= "H:\\xmltodb.xml";
        // File xmlfile= new File(nameoffile);

int x;

try {
    // Declare the file input stream.
    InputStream fis = new FileInputStream(nameoffile);

    // Read in x from the file.  If not EOF then print x out.
    while ((x = fis.read())!= -1) {
        System.out.print(x);

    }

         InputSource insource= new InputSource(fis);


        Database targetModel = new DatabaseIO().read(insource);

        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
        dataSource.setDriverClassName("org.apache.derby.jdbc.ClientDriver");

        boolean    alterDb = false;

        Platform platform = PlatformFactory.createNewPlatformInstance
(dataSource);

        if (alterDb) {
            platform.alterTables(targetModel, false);
        } else {

            platform.createTables(targetModel, true, true);
        }
} catch (Exception e) {
    System.out.print(e.getMessage());
}

i found someone else on this alias who had the same problem
(MalFormedURLException). You see, the problem is that when i run this code
in netbeans java application it works, but as i include it inside a module,
it gives this exception. That other guy i guess had a similar problem in
eclipse. he said that he tired everything, including using other variants of
the read method but the problem didn't go away except when he included
database.dtd and mapping.xml files in ddluitls.jar. Can this be relevant
too? and if that's the case, how can i find these files?

Thanks in advance

Wessam



On 9/18/07, Thomas Dudziak <to...@gmail.com> wrote:
>
> On 9/18/07, Wessam Abd Rabo <we...@gmail.com> wrote:
>
> > The following piece of code creates a MalFormedUrl exception. I just
> read
> > from an XML file and create a database. This is error Trace:
> >
> > org.apache.ddlutils.DdlUtilsException: java.net.MalformedURLException
> >  at org.apache.ddlutils.io.DatabaseIO.read(DatabaseIO.java:172)
> >
> >
> > This is the only code i write:
> >
> >  String  nameoffile= "xmltodb.xml";
> >         Database targetModel = new DatabaseIO().read(nameoffile);
> >
> >         BasicDataSource dataSource = new BasicDataSource();
> >         dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
> >         dataSource.setDriverClassName("
> org.apache.derby.jdbc.ClientDriver ");
> >
> >         boolean    alterDb = false;
> >
> >         Platform platform = PlatformFactory.createNewPlatformInstance
> > (dataSource);
> >
> >         if (alterDb) {
> >             platform.alterTables(targetModel, false);
> >         } else {
> >
> >             platform.createTables(targetModel, true, true);
> >         }
>
> Try a different variant of the read method with e.g. a FileInputStream
> that you opened for the xmltodb.xml file.
>
> Tom
>

Re: Urgent: MalformedUrlException

Posted by Thomas Dudziak <to...@gmail.com>.
On 9/18/07, Wessam Abd Rabo <we...@gmail.com> wrote:

> The following piece of code creates a MalFormedUrl exception. I just read
> from an XML file and create a database. This is error Trace:
>
> org.apache.ddlutils.DdlUtilsException: java.net.MalformedURLException
>  at org.apache.ddlutils.io.DatabaseIO.read(DatabaseIO.java:172)
>
>
> This is the only code i write:
>
>  String  nameoffile= "xmltodb.xml";
>         Database targetModel = new DatabaseIO().read(nameoffile);
>
>         BasicDataSource dataSource = new BasicDataSource();
>         dataSource.setUrl("jdbc:derby://localhost:1527/instancedb");
>         dataSource.setDriverClassName("org.apache.derby.jdbc.ClientDriver");
>
>         boolean    alterDb = false;
>
>         Platform platform = PlatformFactory.createNewPlatformInstance
> (dataSource);
>
>         if (alterDb) {
>             platform.alterTables(targetModel, false);
>         } else {
>
>             platform.createTables(targetModel, true, true);
>         }

Try a different variant of the read method with e.g. a FileInputStream
that you opened for the xmltodb.xml file.

Tom