Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nobuh/81a8adfe6e0959a4659c6b4e42a215f7 to your computer and use it in GitHub Desktop.
Save nobuh/81a8adfe6e0959a4659c6b4e42a215f7 to your computer and use it in GitHub Desktop.
Setup instructions for installing and configuring the SimpleDB Server and Client Database

SimpleDB Setup Instructions

Download

SimpleDB can be downloaded here: http://bcs.wiley.com/he-bcs/Books?action=resource&bcsId=4570&itemId=0471757160&resourceId=14355

Structure

  1. simpledb - The server side code for the database.
  2. studentclient - Example client-side code for the database
  3. javadoc - API for the database

Windows vs Mac vs Linux

Most instructions are the same between all three platforms, except for a few commands.

  • Start is not a command in mac and Linux, so append the command with an & instead

    • Start command vs command &
  • Variables in Macs and Linuxes are used differently than they are in Windows

    • To print the PATH variable in Windows: echo %PATH%
    • To print it on Mac or Linux: echo $PATH
    • Variables on both platforms must always be in ALL CAPS for them to be recognized
  • Directories in Path variables are separted by : in Mac/Linux and ; in Windows

  • The home directory path is different for mac/linux and windows. If your username is username , then on mac/linux, the location would be: /Users/username/ and on windows it would be C:\Users\username. I will use username as the user name for the rest of the document, so replace it with what your actual username is.

Installation

  1. Make sure that Java is installed.

    #run
    javac -version
    

    If the command is unrecognized, make sure that you install Java, and that the executable is in your path. If it prints the version number, skip to step 2.

    Otherwise, find the location where Java is installed, and in there the path to the bin directory.

    On Mac/Linux: Open the file ~/.bash_profile (from the terminal or a text editor), and add export path="{java bin location}:"$path" to the end of the file.

    On Windows: Go to Control Panel -> Advanced System Settings -> Environment Variables. From here, find the System Variables pane at the bottom, and the path variable in it. Edit it, and add ;{java bin location} to the end of the value string.

    Note: Replace {java bin location} with the actual path to the bin directory in java installation location. Do not include the {} braces.

    Note for Linux Users: The bash init file is located at .bashrc, so either add the path to bashrc, or add source ~/.bash_profile after completing the above steps to the bashrc.

  2. Download the Simpledb code from the download location above, and extract it to a working path, for instance /Users/username/javalib (on mac/linux), or C:\Users\username\javalib (on windows).

    Once extracted, the javalib directory should have the following files and folders listed within it:

    • javadoc
    • README.txt
    • simpledb
    • studentclient
  3. Add the javalib location to your CLASSPATH variable. On Mac/Linux: Open the file ~/.bash_profile (from the terminal or a text editor), and add export CLASSPATH="/Users/username/javalib:.:"$CLASSPATH" to the end of the file.

    On Windows: Go to Control Panel -> Advanced System Settings -> Environment Variables. From here, find the System Variables pane at the bottom. If the CLASSPATH variable exists, edit it, otherwise create a new one with that name. Edit it's value, and add ;C:\Users\username\javalib;.; to the end of its value string.

    Replace javalib with the actual directory you extracted your SimpleDB files to. Note that you need to add both the javalib location and a . directory in the classpath. This is to make sure that Java is able to find .class files in the current directory it is being called from.

  4. Open the terminal (on mac/linux) or Command Prompt (on windows) (if you already had a terminal/command prompt window open, close it and open a new session), and navigate to the javalib directory

    #mac/linux
    cd /Users/username/javalib
    
    #windows
    cd C:\Users\username\javalib
    
  5. Compile the Server code

    #all platforms
    cd simpledb
    cd server
    javac *.java
    
  6. Run the Server code

    cd ..
    cd ..
    java simpledb.server.Startup studentdb
    
  7. Open a new terminal or command prompt window, follow step 4. (You should put both terminal windows side-by-side so you can monitor output on both terminals together).

  8. Go into the student client folder, compile the program files in it, and run the client code.

    cd studentClient
    cd simpledb
    javac *.java
    #ignore any warnings
    java CreateStudentDB
    

Once you run the CreateStudentDB, you should see transactions executed from the client succesfully being processed on the server side. You should open the CreateStudent.java file and understand how it connects to the server database, how it executes queries, and be able to execute your own queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment