Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
When you try to write data from a xml file into the database using the ant-task <ddlToDatabase> you'll get a "java.net.MalformedURLException: unknown protocol: " exception.
For example this task:
<ddlToDatabase usedelimitedsqlidentifiers="true" schemafile="db-schema.xml">
<database url="jdbc:derby:directory:C:/Temp/derbydb;create=true;" driverClassName="org.apache.derby.jdbc.EmbeddedDriver" />
<createDatabase failonerror="false" />
<writeSchemaToDatabase />
<writeDataToDatabase failonerror="false" datafile="data.xml" />
</ddlToDatabase>
Here i get a "java.net.MalformedURLException: unknown protocol: d" exception.
Problem is the code
try
{ getDataIO().writeDataToDatabase(reader, dataFile.getAbsolutePath()); _log.info("Written data from file " + dataFile.getAbsolutePath() + " to database"); }in WriteDataToDatabaseCommand.java. writeDataToDatabase uses the second argument to call the method parse on a Digester object. This object interpretes the argument as an URI, trying to use the D from "D:/..." as a protocol identifier.
I fixed this with a quick-and-dirty hack:
try
{ getDataIO().writeDataToDatabase(reader, "file:///" + dataFile.getAbsolutePath()); // THIS LINE HAS CHANGED _log.info("Written data from file " + dataFile.getAbsolutePath() + " to database"); }