JaroslavTulach: /* On Classpath Database */ - 2010-07-17 07:32:03

On Classpath Database

←Older revision Revision as of 07:32, 17 July 2010
Line 17: Line 17:
==== On Classpath Database ====
==== On Classpath Database ====
-
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].
+
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]] (the last ''db'' is relative path to root of classpath elements).
==== Perfect Match ====
==== Perfect Match ====

JaroslavTulach: /* Shut the Database Down */ - 2010-07-17 07:30:52

Shut the Database Down

←Older revision Revision as of 07:30, 17 July 2010
Line 13: Line 13:
==== Shut the Database Down ====
==== Shut the Database Down ====
-
The last problem that I had to face was inconsistent state of the database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
+
The last problem that I had to face was inconsistent state of the database. To eliminate that, you need to shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
==== On Classpath Database ====
==== On Classpath Database ====

JaroslavTulach: /* Shutdown the Database */ - 2010-07-17 07:30:32

Shutdown the Database

←Older revision Revision as of 07:30, 17 July 2010
Line 11: Line 11:
<source lang="xml" snippet="livedb.derby.create"/>
<source lang="xml" snippet="livedb.derby.create"/>
-
==== Shutdown the Database ====
+
==== Shut the Database Down ====
The last problem that I had to face was inconsistent state of the database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
The last problem that I had to face was inconsistent state of the database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).

JaroslavTulach at 07:29, 17 July 2010 - 2010-07-17 07:29:28

←Older revision Revision as of 07:29, 17 July 2010
Line 1: Line 1:
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I decided to use it to demonstrate functionality of the [[LiveDB]] project.
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I decided to use it to demonstrate functionality of the [[LiveDB]] project.
 +
 +
=== [[Derby]] and [[Ant]] ===
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. Then the database shall be discarded.
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. Then the database shall be discarded.
 +
 +
==== Embed or Connect? ====
For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use. One of its benefits is that one does not need to start separate process. Whenever one needs a database, it is enough to create the driver and use it (but don't forget to shut the database down if you modify it):
For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use. One of its benefits is that one does not need to start separate process. Whenever one needs a database, it is enough to create the driver and use it (but don't forget to shut the database down if you modify it):
Line 7: Line 11:
<source lang="xml" snippet="livedb.derby.create"/>
<source lang="xml" snippet="livedb.derby.create"/>
 +
==== Shutdown the Database ====
-
The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
+
The last problem that I had to face was inconsistent state of the database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
 +
 
 +
==== On Classpath Database ====
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].
 +
 +
==== Perfect Match ====
[[Derby]] comes with huge amount of documentation. However it seems to cover everything else than usage in unit tests and scripting with [[Ant]]. I could not google out any sufficient how to, thus I wrote this one. I hope it will be useful for those who want to merge [[Ant]] and [[Derby]] database in similar ways.
[[Derby]] comes with huge amount of documentation. However it seems to cover everything else than usage in unit tests and scripting with [[Ant]]. I could not google out any sufficient how to, thus I wrote this one. I hope it will be useful for those who want to merge [[Ant]] and [[Derby]] database in similar ways.
<comments/>
<comments/>

JaroslavTulach at 07:26, 17 July 2010 - 2010-07-17 07:26:12

←Older revision Revision as of 07:26, 17 July 2010
Line 8: Line 8:
-
The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. However even this is easier than writing own [[Ant]] task (as suggested elsewhere on the blogosphere).
+
The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. In spite of that I consider this more elegant than writing own [[Ant]] task (as suggested [http://www.ibm.com/developerworks/data/library/techarticle/dm-0412snell/ elsewhere] on the blogosphere; btw. that article is from year 2004, so it clearly shows how ''big'' process [[Ant]] made since then).
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].

JaroslavTulach at 07:23, 17 July 2010 - 2010-07-17 07:23:46

←Older revision Revision as of 07:23, 17 July 2010
Line 1: Line 1:
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I decided to use it to demonstrate functionality of the [[LiveDB]] project.
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I decided to use it to demonstrate functionality of the [[LiveDB]] project.
-
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use:
+
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. Then the database shall be discarded.
 +
 
 +
For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use. One of its benefits is that one does not need to start separate process. Whenever one needs a database, it is enough to create the driver and use it (but don't forget to shut the database down if you modify it):
<source lang="xml" snippet="livedb.derby.create"/>
<source lang="xml" snippet="livedb.derby.create"/>
Line 8: Line 10:
The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. However even this is easier than writing own [[Ant]] task (as suggested elsewhere on the blogosphere).
The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. However even this is easier than writing own [[Ant]] task (as suggested elsewhere on the blogosphere).
-
I could not google out any sufficient how to, thus I am writing this one. I hope it will be useful for those who want to merge [[Ant]] and [[Derby]] database.
+
You may notice that I am creating the database inside ''build/classes'' directory. E.g. on the application classpath. This allows my tests to reference the database with location agnostic ''jdbc:derby:classpath:db'' [[URL]].
 +
 
 +
[[Derby]] comes with huge amount of documentation. However it seems to cover everything else than usage in unit tests and scripting with [[Ant]]. I could not google out any sufficient how to, thus I wrote this one. I hope it will be useful for those who want to merge [[Ant]] and [[Derby]] database in similar ways.
<comments/>
<comments/>

JaroslavTulach at 07:19, 17 July 2010 - 2010-07-17 07:19:09

←Older revision Revision as of 07:19, 17 July 2010
Line 1: Line 1:
-
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I also decided to use it to demonstrate functionality of the [[LiveDB]] project.
+
[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I decided to use it to demonstrate functionality of the [[LiveDB]] project.
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use:
It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use:

JaroslavTulach: New page: Derby (also known as Java DB) is a lightweight, embeddable SQL database. It is very useful while running tests. I also decided to use it to demonstrate f... - 2010-07-17 06:46:23

New page: Derby (also known as Java DB) is a lightweight, embeddable SQL database. It is very useful while running tests. I also decided to use it to demonstrate f...

New page

[[wikipedia:Apache_Derby|Derby]] (also known as [[Java]] DB) is a lightweight, embeddable [[SQL]] database. It is very useful while running tests. I also decided to use it to demonstrate functionality of the [[LiveDB]] project.

It took me about two days to find out how to configure the [[Derby]] database through [[Ant]] build script. I wanted the [[Ant]] script to start the database, create there a table, fill it with some sample data and then compile and execute associated unit tests. For a while I was oscillating between using embedded driver vs. starting the server and connecting to it via socket. At the end the embedded driver turned to be easier to use:

<source lang="xml" snippet="livedb.derby.create"/>


The last problem that I had to face was inconsistent state of a database. To eliminate that, you need to close the shut the database down. As far as I can tell this cannot be done in [[Ant]] (version 1.8.1) without having an ''<sql>'' target that fails and print a nasty warning. However even this is easier than writing own [[Ant]] task (as suggested elsewhere on the blogosphere).

I could not google out any sufficient how to, thus I am writing this one. I hope it will be useful for those who want to merge [[Ant]] and [[Derby]] database.

<comments/>