Cross-platform SQL scripts

From: Todd O'Bryan (toddobrya..ac.com)
Date: Tue Dec 14 2004 - 21:24:46 EST

  • Next message: Andrus Adamchik: "Re: Accessing last commit status"

    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 : Tue Dec 14 2004 - 21:24:52 EST