Installation Instructions for MySql, Resin and Homework Set 4.

Most of you told us early in the semester that you had access to PC's running Windows, so we have chosen tools that should work easily in that environment.  For the (I hope) few of you who do not have access to such an environment, please contact Delin or Peter Sz. directly for help.  Here is what you will need to install if you don't already have it on your machine.

  1. The MySql database.  You may already have installed this for the first homework problem set.  If not, you can download a distribution from http://dev.mysql.com/.  I'm using Production version 4.0.17, though I notice that 4.0.18 is current.  For purposes of this assignment, please stay away from the less stable Development or Preview editions.  Here are steps to set up MySql on your machine, if you need them:
    1. Expand the zip file, mysql-4.0.18-win.zip that you downloaded.  If you don't have Windows XP (which innately knows how to unzip such archives), you will need to get winzip or some such utility.
    2. If you run the Setup.exe file in that archive (this may be done for you automagically by the unzip utility), just approve the default answers.  This will install MySql at C:\mysql\.
    3. You can then either run MySql by giving the command
      C:\mysql\bin\mysqld-nt
      at a command prompt or you can install MySql to be run automatically as a service by giving the command
      C:\mysql\bin\mysqld-nt --install
      After this, MySql runs automatically whenever you start your machine.  It may be controlled by
      net stop mysql
      and
      net start mysql
      at a command prompt.
    4. For your convenience, you could also add C:\mysql\bin to your PATH.  Use the System Control Panel to do so.
  2. Install the database(s) for this assignment.  Each database is just a subdirectory in C:\mysql\data\.  We distribute the files as ZIP archives.  You will need to unzip them and then move the directories into this data directory.  The command "show databases" in the MySql client will show you the ones it knows about.
    1. From homework assignment 1, download the cwsscrubbed database: MySQL version.  Unzip it and move it into the data directory.
    2. Download this simple demo database, unzip it and move it into the data directory.  This will be useful in illustrating some of the data access abstractions we use.
  3. Install the Resin web server.  I am using the "enterprise edition", which has facilities for interaction with databases.  You can get the latest version from http://www.caucho.com, or version resin-ee-3.0.7.zip from our site.
    1. Expand the installation file to wherever you would like it to live.  E.g., C:\resin-ee-3.0.7\.  You may run setup.exe in its bin directory to connect Resin to Apache or MS's IIS and to define the home directory to other parts of the system.  To actually run the server, run
      C:\resin-ee-3.0.7\bin\httpd
      or double-click the dragon-fly-icon's httpd.exe file in that directory.  The server should start up, and then respond to url's such as http://localhost:8080/.
    2. If you see errors during Resin's startup, that probably means that you do not have a Java Development Kit installed on your machine.  If this is so, follow these instructions:
      1. At http://java.sun.com/j2se/1.4.2/download.html, download either J2SE v 1.4.2_04 SDK or that bundled with NetBeans (a GUI development environment).  I use the NetBeans bundle because the environment does a nice job of showing documentation as I code.  If I needed this less, I'd probably just use Emacs to edit.
      2. Re-try running the Resin server.
    3. To get jdbc connectivity to work, you need to download this .jar file to your machine and move it into the directory C:\resin-ee-3.0.7\jar.  (I don't understand why this is not part of the standard Resin distribution, because its configuration file uses it, but apparently you need to do this manually.)
  4. You need to edit the configuration file for Resin, C:\resin-ee-3.0.7\conf\resin.conf, to tell Resin how to access your new MySql databases.

    The configuration file by default defines a database whose JNDI name is jdbc/mysql and which is known by MySql as "test" via the following XML:

    <database>
      <jndi-name>jdbc/mysql</jndi-name>
      <driver type="org.gjt.mm.mysql.Driver">
        <url>jdbc:mysql://localhost:3306/test</url>
        <user></user>
        <password></password>
       </driver>
      <prepared-statement-cache-size>8</prepared-statement-cache-size>
      <max-connections>20</max-connections>
      <max-idle-time>30s</max-idle-time>
     </database>

    You need to replicate this for each database to be accessed by your code.  For example, we might define the JNDI name for our Clinician's Workstation database as "jdbc/cws" and the name of the MySql database (in the <url> entry) needs to be "cwsscrubbed".  Similarly, for our update demo, we associate the JNDI name "jdbc/demo" with the database "demo".

  5. Now install the DBWeb abstractions that we provide into the Web server.  Download the DBWeb.jar file and place it (not expanded) into the directory C:\resin-ee-3.0.7\jar.
  6. To avoid complex configuration problems, the easiest way to deploy "Web Applications" on your system is simply to create subdirectories for each one under C:\resin-ee-3.0.7\webapps\.  For example, if we want the "demo" application (see below) to run under Resin, we can simply place its three .jsp files in the directory C:\resin-ee-3.0.7\webapps\demo\.  If you then use your web browser to open the URL http://localhost:8080/demo/index.jsp or just http://localhost:8080/demo/, that will create a response from the index.jsp file in that directory.  You can download demofiles.zip, which contains these files in the directory demo.  If you expand it and move it into the webapps directory, you should be set.  Similarly, you can download cws.zip, which will expand into a directory, cws, that you can also place into the webapps directory.

You have now endured the most painful part of developing code for a sophisticated web application: making sure the environment is configured and installed properly.

At this point, you should be able to play with a tiny database of MIT classes and professors, including forms that should allow you to define new professors and classes, and to associate faculty with classes.  You should also be able to explore the beginnings of a Web interface to the CWS database.