SimpleDB can be downloaded here: http://bcs.wiley.com/he-bcs/Books?action=resource&bcsId=4570&itemId=0471757160&resourceId=14355
- simpledb - The server side code for the database.
- studentclient - Example client-side code for the database
- javadoc - API for the database
Most instructions are the same between all three platforms, except for a few commands.
-
Startis not a command in mac and Linux, so append the command with an&insteadStart commandvscommand &
-
Variables in Macs and Linuxes are used differently than they are in Windows
- To print the
PATHvariable 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
- To print the
-
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 beC:\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.
-
Make sure that Java is installed.
#run javac -versionIf 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
bindirectory.On Mac/Linux: Open the file
~/.bash_profile(from the terminal or a text editor), and addexport 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 Variablespane at the bottom, and thepathvariable 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 thebindirectory 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 addsource ~/.bash_profileafter completing the above steps to the bashrc. -
Download the Simpledb code from the download location above, and extract it to a working path, for instance
/Users/username/javalib(on mac/linux), orC:\Users\username\javalib(on windows).Once extracted, the
javalibdirectory should have the following files and folders listed within it:- javadoc
- README.txt
- simpledb
- studentclient
-
Add the
javaliblocation to yourCLASSPATHvariable. On Mac/Linux: Open the file~/.bash_profile(from the terminal or a text editor), and addexport 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 Variablespane at the bottom. If theCLASSPATHvariable 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
javalibwith the actual directory you extracted your SimpleDB files to. Note that you need to add both thejavaliblocation and a.directory in theclasspath. This is to make sure that Java is able to find.classfiles in the current directory it is being called from. -
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
javalibdirectory#mac/linux cd /Users/username/javalib #windows cd C:\Users\username\javalib -
Compile the Server code
#all platforms cd simpledb cd server javac *.java -
Run the Server code
cd .. cd .. java simpledb.server.Startup studentdb -
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).
-
Go into the
student clientfolder, 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.