Here is some information on how to get your toy web application ready for phase_I of your project.
In short, you have to create a set of web pages that will have a connection to database. These pages should be served by a web server, and you have several options for selecting the web server, database or environment to use.


Option 1: Tomcat + JSP + Oracle
Use the Oracle DBMS, which you can access through your glue accounts, with Apache's Tomcat web server and JSP at the backend. For more information on installing Tomcat to your glue accounts and using JSP, see previous TA's webpage (NOTE: This information is outdated and the commands may not work).


Option 2: Ruby On Rails + Oracle
Ruby is an object oriented scripting language. Rails is a Model-View-Controller framework based on Ruby and used for developing web applications. It includes a built-in web server, WEBrick, so you don't need to install an additional web server. Rails framework supports several databases including Oracle, MySQL, PostgreSQL, SQL Server, and DB2.

Installing Ruby, and Rails

Follow this link to install Ruby for your system.


Grace cluster users:

Download the source from the link above and extract it.

Change dir to where you extracted it.

Run configure script to specify where you want to install it. This script is used as follows:

./configure --prefix=/place/where/you/want/to/install

Let’s call the path you gave to prefix $RUBY_HOME (This is not an environment variable, just a reference in this text for the sake of explanation)

Run:

make

make test

make install

At this point, Ruby executable will be under the directory bin under the directory you specified for the configure script.

Use the following command to make Ruby executable visible:

setenv PATH RUBY_HOME/bin:$PATH



After installing Ruby, you should install Ruby's package manager, RubyGems. For that, download the corresponding file fromhere; extract it and run

ruby setup.rb


Now you can use gem package manager to install the additional packages that are needed, first of which is the Rails framework. Run

gem install rails --include-dependencies

to get Rails framework.


Installing Oracle Instant Client

First you need to install is the Oracle Instant Client:

Follow this link.

Select your system and download most current versions of these two files: Instant Client Package - Basic (~40MB) and Instant Client Package - SDK (~1MB).

Grace cluster users:

Use Linux x86-64 option


Unzip the packages to the same directory (simply do not specify a target directory and they will be unzipped under the current directory under a directory called instantclient_11_1)

Grace cluster users:

If instantclient_11_1/libclntsh.so is not found, make a symbolic link to link the library.

cd instantclient_11_1

ln -s libclntsh.so.11.1 libclntsh.so

Set your OS's library search path to point to the installed location (for example~/project/instantclient_11_1 ). For Windows, this variable is the PATH variable, and for Unix it is the LD_LIBRARY_PATH variable.

Installing Ruby OCI8

Download and install ruby oci 8 from here

Grace cluster users:

Download the source version from the link above (tar.gz format, last version is 1.0.6), extract it and install it as follows:

gzip -dc ruby-oci8-VERSION.tar.gz | tar xvf -

cd ruby-oci8-VERSION

make

make install

Installing ActiveRecord Adapter

Run the following command

gem install activerecord-oracle-adapter --source http://gems.rubyonrails.org

This should install Oracle’s ActiveRecord adapter.


HelloWorld Example

Login to sqlplus

Create a state codes table and populate it:

CREATE TABLE CODES

(ID NUMBER(38) NOT NULL,

CODE VARCHAR(50),

STATE VARCHAR(50),

CONSTRAINT PKID PRIMARY KEY (ID));

INSERT INTO CODES VALUES (1, 'MD', 'MARYLAND');

INSERT INTO CODES VALUES (2, 'NY', 'NEW YORK');

INSERT INTO CODES VALUES (3, 'NJ', 'NEW JERSEY');

Note that a field called ID is required for Ruby as a means for accessing the records.


Exit sqlplus and create the workspace for your project:

rails codes –d oracle

cd codes

Edit the codes/conf/database.yml to look like this:

development:

adapter: oracle

database: ginger.umd.edu/dbclass2

username: YOUR ORACLE USERNAME

password: YOUR ORACLE PASSWORD

Replace the file's text with the text above. Do not forget to change the database parameter in addition to your username and password.


There are a number of approaches to creating a Web application in Rails, but the simplest by far is to use scaffold, a command line feature in Rails, which will build the entire application in a single command.

ruby script/generate scaffold code code:string state:string


Now we are ready to start the web server.

ruby script/server


Goto URL: http://localhost:3000/codes/ in your browser.


Play with the website. Add and remove tuples. You can also check and see if they really modify the database.


Now, let's write/execute an actual SQL query of our own.

Open the codes_controller.rb file in ~/codes/app/controllers/ directory.

Replace the line in index function, which says

@codes = Code.all

with

@codes = Code.find_by_sql("SELECT * FROM codes WHERE country LIKE 'N%'")


Now we should be getting states starting with 'N' only.





Option 3: Ruby On Rails + MySQL

Installing MySQL:

Check this page for installing MySQL database on your system.

Installing Ruby MySQL Connectors:

Run 'gem install mysql' to get the ruby mysql connector.

You can go through the above example application with the only difference in the ~/config/database.yml database configuration, which should be as given in this example database configuration file. (Don't forget to change username, password and database name fields!)


Other options:
Apache + MySQL + PHP is another frequently used environment.
Examples will be provided if needed ...


References:


CMSC 424, Fall 2009: Project Information and Links


Class Page
Class Forum
SQL/Html
Oracle/MySQL
Ruby On Rails
Other