Todd,
I think it totally makes sense to setup the db on your student machines
with ant after they create their initial logins.
There is a still uncommitted DbGeneratorTask contributed by Kevin Menard
that should hopefully cover the schema creation:
http://objectstyle.org/jira/secure/ViewIssue.jspa?key=CAY-82
And core Ant has SQL task (that I never tried myself):
http://ant.apache.org/manual/CoreTasks/sql.html
I think in most cases you should also be able to create the DB itself from
Ant if you do't want to use MySQL command line tools. IIRC some drivers
support the option of automatic DB creation when you connect to a
non-existing DB. Read MySQL driver docs, it may have some URL parameters
that support that. And I am sure that all databases allow to create a new
DB using a SQL statement if you have a valid login on the system... If you
use this option you will probably need to reconnect with a different URL.
Andrus
> I have been bitten in the butt.
>
> Today was day 1 of my students' first semester final. They had to
> examine a project I've been working on to figure out how some stuff
> works. In order to do that, I wrote a script to run some SQL scripts to
> set up the database.
>
> I followed a plan which seemed to make sense when it was suggested on
> this list in that, as the project evolved, I kept SQL scripts that
> represented each phase, so that, all run in sequence, they got to the
> database I currently have. To run them in sequence, the students had to
> create a user account in MySQL, create the database, and run a script.
> Using Cygwin for the bash script, that part went reasonably well.
>
> Then all hell broke loose. I had written a Java class that read simple
> text files and used Cayenne to throw a bunch of sample data into the
> database. Going from my Mac to the lab's window machines, the script to
> run the class had a plethora of classpath and other problems.
>
> I now realize that I should have probably used Ant to deal with the
> Java part of the whole thing, but if I'm using Ant for the Java part,
> it would be really nice to automate the database building. Is there an
> easy way to run a SQL script using Java? Hopefully hidden somewhere in
> Cayenne? I tried just reading a line of the script and running it
> through JDBC, but if statements are split over several lines you have
> to concatenate them. Also, I don't know how much you can really do? Can
> I create a database in MySQL using Java for example? (I'm thinking no,
> since the URL includes the database name already.)
>
> Thanks,
> Todd
This archive was generated by hypermail 2.0.0 : Wed Dec 15 2004 - 09:43:03 EST