You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by ka...@eng.iastate.edu on 2006/06/14 19:55:15 UTC
The tutorial on migrating DB to derby
Hi,
I was just going through the tutorial at
http://db.apache.org/derby/integrate/db_ddlutils.html
I am having a problem checking out the ddlutils files from
http://svn.apache.org/repos/asf/db/ddlutils/trunk STEP 2.
It says cannot connect to the server. My internet connection is perfect
and I dont understand why it does not allow me to checkout stuff.
Could you please help me out with this.
Thanks,
Kamna
Re: The tutorial on migrating DB to derby
Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
kamna@eng.iastate.edu wrote:
> Hi,
> I was just going through the tutorial at
> http://db.apache.org/derby/integrate/db_ddlutils.html
>
> I am having a problem checking out the ddlutils files from
> http://svn.apache.org/repos/asf/db/ddlutils/trunk STEP 2.
>
> It says cannot connect to the server. My internet connection is perfect
> and I dont understand why it does not allow me to checkout stuff.
>
> Could you please help me out with this.
>
> Thanks,
> Kamna
Below is the response I posted to derby-user.
-jean
-------- Included Message --------
Subject: Re: The tutorial on migrating DB to derby
Date: Wed, 14 Jun 2006 11:09:52 -0700
From: Jean T. Anderson <jt...@bristowhill.com>
Reply-To: Derby Discussion <de...@db.apache.org>, jta@bristowhill.com
To: Derby Discussion <de...@db.apache.org>
References: <42...@mail.eng.iastate.edu>
kamna@eng.iastate.edu wrote:
> Hi,
> I was just going through the tutorial at
> http://db.apache.org/derby/integrate/db_ddlutils.html
>
> I am having a problem checking out the ddlutils files from
> http://svn.apache.org/repos/asf/db/ddlutils/trunk STEP 2.
>
> It says cannot connect to the server. My internet connection is perfect
> and I dont understand why it does not allow me to checkout stuff.
>
> Could you please help me out with this.
>
hmmm, I just tried and it worked for me. Try https instead:
svn co https://svn.apache.org/repos/asf/db/ddlutils/trunk ddlutils
Also, can you access this URL in your browser?
https://svn.apache.org/repos/asf/db/ddlutils/trunk
regards,
-jean
Re: The tutorial on migrating DB to derby
Posted by Thomas Dudziak <to...@gmail.com>.
On 6/15/06, Kathey Marsden <km...@sbcglobal.net> wrote:
> Please note, my hack of a patch is not ready and needs adjustment.
> It calls Clob.length() twice which may be a performance issue on some
> systems and I haven't tested it with BLOB's and looking at the code now
> I see it is flat out wrong.
>
> I'll file an issue with DdlUtils so someone can fix it right and will
> follow up with derby-dev on the getSubString issue. Even if fixed in
> DERBY it would great to see a fix in DdlUtils, since it would then work
> with existing Derby versions.
No need to file an issue with DdlUtils, I've just committed the fix
(with appropriate changes to the Blob handling).
cheers,
Tom
Re: The tutorial on migrating DB to derby
Posted by Kathey Marsden <km...@sbcglobal.net>.
Thomas Dudziak wrote:
> On 6/15/06, Kathey Marsden <km...@sbcglobal.net> wrote:
>
>> The problem was just that ddlutils was not handling the case where the
>> lob length was 0, but it was not null (an empty string was in the CLOB
>> column)
>> The hack of a patch below got me going.
>
>
> Mhmm, the Clob Javadoc does not explicitly state what should happen if
> the length is 0. Then again, it does not say that an exception will be
> thrown, either, so I would assume that 0 should be regarded as a valid
> value.
> Anyway, I'll add your patch as a safety measure to DdlUtils
Please note, my hack of a patch is not ready and needs adjustment.
It calls Clob.length() twice which may be a performance issue on some
systems and I haven't tested it with BLOB's and looking at the code now
I see it is flat out wrong.
I'll file an issue with DdlUtils so someone can fix it right and will
follow up with derby-dev on the getSubString issue. Even if fixed in
DERBY it would great to see a fix in DdlUtils, since it would then work
with existing Derby versions.
Kathey
Re: The tutorial on migrating DB to derby
Posted by Thomas Dudziak <to...@gmail.com>.
On 6/15/06, Kathey Marsden <km...@sbcglobal.net> wrote:
> The problem was just that ddlutils was not handling the case where the
> lob length was 0, but it was not null (an empty string was in the CLOB
> column)
> The hack of a patch below got me going.
Mhmm, the Clob Javadoc does not explicitly state what should happen if
the length is 0. Then again, it does not say that an exception will be
thrown, either, so I would assume that 0 should be regarded as a valid
value.
Anyway, I'll add your patch as a safety measure to DdlUtils.
> Thanks so, so, much to DdlUtils and to Jean for the great tutorial to
> get me going in a hurry.
> I used DdlUtils to migrate data when trying to recover a database for a
> user that had a corrupted database today.
> (some business about removing a pesky db.lck file that wouldn't let them
> boot their database).
> All the user's backups were corrupt and we don't have import/export
> for lobs yet (DERBY-378),
> so I was completely stuck until I found DdlUtils which I found easy to
> use and really saved my day.
Thanks, good to hear that DdlUtils was useful to somebody :-)
cheers,
Tom
Re: The tutorial on migrating DB to derby
Posted by Kathey Marsden <km...@sbcglobal.net>.
Thomas Dudziak wrote:
>
> seems to be ok according to the Clob javadocs
> (http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Clob.html#getSubString(long,%20int)),
>
> right ? A string is only returned (and getSubString called) if the
> length of the clob is within int range, so length() seems to return a
> value <= 0 ?
>
The problem was just that ddlutils was not handling the case where the
lob length was 0, but it was not null (an empty string was in the CLOB
column)
The hack of a patch below got me going.
Thanks so, so, much to DdlUtils and to Jean for the great tutorial to
get me going in a hurry.
I used DdlUtils to migrate data when trying to recover a database for a
user that had a corrupted database today.
(some business about removing a pesky db.lck file that wouldn't let them
boot their database).
All the user's backups were corrupt and we don't have import/export
for lobs yet (DERBY-378),
so I was completely stuck until I found DdlUtils which I found easy to
use and really saved my day.
Index: src/java/org/apache/ddlutils/platform/PlatformImplBase.java
===================================================================
--- src/java/org/apache/ddlutils/platform/PlatformImplBase.java
(revision 414353)
+++ src/java/org/apache/ddlutils/platform/PlatformImplBase.java (working
copy)
@@ -1956,6 +1956,10 @@
{
value = clob;
}
+ else if (clob.length() == 0)
+ {
+ value = "";
+ }
else
{
value = clob.getSubString(1l,
(int)clob.length());
@@ -1968,6 +1972,10 @@
{
value = blob;
}
+ else if (blob.length() == 0)
+ {
+ value = "";
+ }
else
{
value = blob.getBytes(1l, (int)blob.length());
Re: The tutorial on migrating DB to derby
Posted by Thomas Dudziak <to...@gmail.com>.
On 6/14/06, Kathey Marsden <km...@sbcglobal.net> wrote:
<snip>
> Caused by: SQL Exception: Zero or negative length argument '0' passed in
> a BLOB or CLOB method.
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:80)
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
> at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:166)
> at
> org.apache.derby.impl.jdbc.EmbedClob.getSubString(EmbedClob.java:206)
> at
> org.apache.ddlutils.platform.PlatformImplBase.extractColumnValue(PlatformImplBase.java:1961)
<snip>
Well, I haven't done much with Clobs lately, but the code in question
Clob clob = resultSet.getClob(columnName);
if ((clob == null) || (clob.length() > Integer.MAX_VALUE))
{
value = clob;
}
else
{
value = clob.getSubString(1l, (int)clob.length());
}
seems to be ok according to the Clob javadocs
(http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Clob.html#getSubString(long,%20int)),
right ? A string is only returned (and getSubString called) if the
length of the clob is within int range, so length() seems to return a
value <= 0 ?
Tom
Re: The tutorial on migrating DB to derby
Posted by Kathey Marsden <km...@sbcglobal.net>.
Kathey Marsden wrote:
> Jean T. Anderson wrote:
>
>> kamna@eng.iastate.edu wrote:
>>
>>
>>> Hi,
>>> I was just going through the tutorial at
>>> http://db.apache.org/derby/integrate/db_ddlutils.html
>>>
>>>
>>
> I am going through this tutorial too today. I got through the
> tutorial fine but on migrating another db I see the exception below #:(
> Perhaps DdlUtils is calling Clob.getSubString with an invalid length
> value in this case?
>
>
Jean suggested I post the DDL for the table.
Changing the book sample database to have a clob column of the same
size worked ok.
Here is the DDL for the table.
CREATE TABLE "APP"."CEG" ("CUUID" CHAR(36) NOT NULL, "CCUUID" CHAR(36)
NOT NULL, "CSECTION" CHAR(6) NOT NULL, "CSTATUS" CHAR(8) NOT NULL,
"CNAME" VARCHAR(255) NOT NULL, "CXMLDATA" CLOB(10485760) NOT NULL,
"CLASTUPDATE" TIMESTAMP NOT NULL);
> EXCEPTION:
> SQL Exception: Zero or negative length argument '0' passed in a BLOB
> or CLOB method.
>
> JDBCAPI CALL
> http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Clob.html#getSubString(long,%20int)
>
>
> FULL TRACE:
> export-source-db:
> [databaseToDdl] Written schema to C:\marsden\ddlutils-test\db-schema.xml
>
> BUILD FAILED
> C:\marsden\ddlutils-test\build.xml:11:
> org.apache.ddlutils.DynaSqlException: Exception while reading the row
> from the resultset
> at
> org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:88)
>
> at
> org.apache.ddlutils.task.DatabaseTaskBase.executeCommands(DatabaseTaskBase.java:198)
>
> at
> org.apache.ddlutils.task.DatabaseTaskBase.execute(DatabaseTaskBase.java:222)
>
> at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
> at org.apache.tools.ant.Task.perform(Task.java:364)
> at org.apache.tools.ant.Target.execute(Target.java:301)
> at org.apache.tools.ant.Target.performTasks(Target.java:328)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
> at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
> at org.apache.tools.ant.Main.runBuild(Main.java:632)
> at org.apache.tools.ant.Main.startAnt(Main.java:183)
> at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
> at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
> Caused by: org.apache.ddlutils.DynaSqlException: Exception while
> reading the row from the resultset
> at
> org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:261)
>
> at org.apache.ddlutils.io.DataWriter.write(DataWriter.java:303)
> at
> org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:82)
>
> ... 12 more
> Caused by: SQL Exception: Zero or negative length argument '0' passed
> in a BLOB or CLOB method.
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:80)
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
> at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:166)
> at
> org.apache.derby.impl.jdbc.EmbedClob.getSubString(EmbedClob.java:206)
> at
> org.apache.ddlutils.platform.PlatformImplBase.extractColumnValue(PlatformImplBase.java:1961)
>
> at
> org.apache.ddlutils.platform.PlatformImplBase.getObjectFromResultSet(PlatformImplBase.java:1885)
>
> at
> org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:251)
>
> ... 14 more
> --- Nested Exception ---
> org.apache.ddlutils.DynaSqlException: Exception while reading the row
> from the resultset
> at
> org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:261)
>
> at org.apache.ddlutils.io.DataWriter.write(DataWriter.java:303)
> at
> org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:82)
>
> at
> org.apache.ddlutils.task.DatabaseTaskBase.executeCommands(DatabaseTaskBase.java:198)
>
> at
> org.apache.ddlutils.task.DatabaseTaskBase.execute(DatabaseTaskBase.java:222)
>
> at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
> at org.apache.tools.ant.Task.perform(Task.java:364)
> at org.apache.tools.ant.Target.execute(Target.java:301)
> at org.apache.tools.ant.Target.performTasks(Target.java:328)
> at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
> at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
> at org.apache.tools.ant.Main.runBuild(Main.java:632)
> at org.apache.tools.ant.Main.startAnt(Main.java:183)
> at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
> at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
> Caused by: SQL Exception: Zero or negative length argument '0' passed
> in a BLOB or CLOB method.
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:80)
> at
> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
> at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:166)
> at
> org.apache.derby.impl.jdbc.EmbedClob.getSubString(EmbedClob.java:206)
> at
> org.apache.ddlutils.platform.PlatformImplBase.extractColumnValue(PlatformImplBase.java:1961)
>
> at
> org.apache.ddlutils.platform.PlatformImplBase.getObjectFromResultSet(PlatformImplBase.java:1885)
>
> at
> org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:251)
>
> ... 14 more
>
> Total time: 14 seconds
> $
>
>
>
Re: The tutorial on migrating DB to derby
Posted by Kathey Marsden <km...@sbcglobal.net>.
Jean T. Anderson wrote:
>kamna@eng.iastate.edu wrote:
>
>
>>Hi,
>>I was just going through the tutorial at
>>http://db.apache.org/derby/integrate/db_ddlutils.html
>>
>>
>>
I am going through this tutorial too today. I got through the
tutorial fine but on migrating another db I see the exception below #:(
Perhaps DdlUtils is calling Clob.getSubString with an invalid length
value in this case?
EXCEPTION:
SQL Exception: Zero or negative length argument '0' passed in a BLOB or
CLOB method.
JDBCAPI CALL
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Clob.html#getSubString(long,%20int)
FULL TRACE:
export-source-db:
[databaseToDdl] Written schema to C:\marsden\ddlutils-test\db-schema.xml
BUILD FAILED
C:\marsden\ddlutils-test\build.xml:11:
org.apache.ddlutils.DynaSqlException: Exception while reading the row
from the resultset
at
org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:88)
at
org.apache.ddlutils.task.DatabaseTaskBase.executeCommands(DatabaseTaskBase.java:198)
at
org.apache.ddlutils.task.DatabaseTaskBase.execute(DatabaseTaskBase.java:222)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:301)
at org.apache.tools.ant.Target.performTasks(Target.java:328)
at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
at org.apache.tools.ant.Main.runBuild(Main.java:632)
at org.apache.tools.ant.Main.startAnt(Main.java:183)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Caused by: org.apache.ddlutils.DynaSqlException: Exception while reading
the row from the resultset
at
org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:261)
at org.apache.ddlutils.io.DataWriter.write(DataWriter.java:303)
at
org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:82)
... 12 more
Caused by: SQL Exception: Zero or negative length argument '0' passed in
a BLOB or CLOB method.
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:80)
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:166)
at
org.apache.derby.impl.jdbc.EmbedClob.getSubString(EmbedClob.java:206)
at
org.apache.ddlutils.platform.PlatformImplBase.extractColumnValue(PlatformImplBase.java:1961)
at
org.apache.ddlutils.platform.PlatformImplBase.getObjectFromResultSet(PlatformImplBase.java:1885)
at
org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:251)
... 14 more
--- Nested Exception ---
org.apache.ddlutils.DynaSqlException: Exception while reading the row
from the resultset
at
org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:261)
at org.apache.ddlutils.io.DataWriter.write(DataWriter.java:303)
at
org.apache.ddlutils.task.WriteDataToFileCommand.execute(WriteDataToFileCommand.java:82)
at
org.apache.ddlutils.task.DatabaseTaskBase.executeCommands(DatabaseTaskBase.java:198)
at
org.apache.ddlutils.task.DatabaseTaskBase.execute(DatabaseTaskBase.java:222)
at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:301)
at org.apache.tools.ant.Target.performTasks(Target.java:328)
at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
at org.apache.tools.ant.Main.runBuild(Main.java:632)
at org.apache.tools.ant.Main.startAnt(Main.java:183)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Caused by: SQL Exception: Zero or negative length argument '0' passed in
a BLOB or CLOB method.
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:80)
at
org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:87)
at
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:166)
at
org.apache.derby.impl.jdbc.EmbedClob.getSubString(EmbedClob.java:206)
at
org.apache.ddlutils.platform.PlatformImplBase.extractColumnValue(PlatformImplBase.java:1961)
at
org.apache.ddlutils.platform.PlatformImplBase.getObjectFromResultSet(PlatformImplBase.java:1885)
at
org.apache.ddlutils.platform.ModelBasedResultSetIterator.next(ModelBasedResultSetIterator.java:251)
... 14 more
Total time: 14 seconds
$
Re: The tutorial on migrating DB to derby
Posted by "Jean T. Anderson" <jt...@bristowhill.com>.
kamna@eng.iastate.edu wrote:
> Hi,
> I was just going through the tutorial at
> http://db.apache.org/derby/integrate/db_ddlutils.html
>
> I am having a problem checking out the ddlutils files from
> http://svn.apache.org/repos/asf/db/ddlutils/trunk STEP 2.
>
> It says cannot connect to the server. My internet connection is perfect
> and I dont understand why it does not allow me to checkout stuff.
>
> Could you please help me out with this.
>
hmmm, I just tried and it worked for me. Try https instead:
svn co https://svn.apache.org/repos/asf/db/ddlutils/trunk ddlutils
Also, can you access this URL in your browser?
https://svn.apache.org/repos/asf/db/ddlutils/trunk
regards,
-jean