Download and Install Mckoi

At this point you should download and install the Mckoi database software, so you can try running the SQL queries, and get the results visually.

To get started, go to the Mckoi website at

www.mckoi.com/database

Click on the “latest version” link under “Download the software.” Download the zip file to your C: top level directory. It is about 2MB in size, so it downloads quite quickly. After the mckoi zip file is on your disk, unpack its contents using a command like this:

cd c:
jar -xvf mckoi1.0.2.zip

That creates a directory called mckoi1.0.2 containing the database binaries and Java source, some documentation, and sample programs.

Set up the Mckoi jar files

Next, make the Mckoi libraries visible to your Java compiler and JVM. There are three jar files in the directory where you just extracted the release. These jar files are:

file name

contents

mckoidb.jar

The database management software

gnu-regexp-1.1.4.jar

GNU regular expression package

mkjdbc.jar

The JDBC driver software

There are several alternative ways of making the Mckoi libraries visible to the compiler and JVM. The simplest is to move the jar files to the ...libext directory of your Java run-time installation. Jar files in here are automatically regarded as part of the standard run-time library.

Be careful to move them to the right directory! The directory or directories that the system actually uses for compiling and for execution can be seen by using the “-verbose” option when you run the compiler or JVM. Look for the pathnames of where the system libraries are picked up. On WinXP, with default installations, the files can be copied as follows:

copy mckoi1.0.2*.jar  "c:program filesjavaj2sdk1.5.0jrelibext"

copy mckoi1.0.2*.jar  "c:program filesjavaj2re1.5.0libext"

The first copy makes the Mckoi libraries visible to the compiler; the second makes them visible to the JVM. (It seems like a gigantic bug waiting to happen that Sun has set things up so the compiler and JVM use different pathnames to (what we hope are the same) libraries).

Running the Mckoi example code

The next step is to run one of the example database programs that accompany the release. Go to the demo directory with this command:

cd c:mckoi1.0.2demosimple

Then run the sample database application that comes with the release. Use this command (assuming you have put the Mckoi jar files in the ...libext directories):

java  SimpleApplicationDemo

If all is well, you will see some output similar to the following, assuring you that the database libraries have been properly installed.

Rows in 'Person' table: 12
Average age of people:  30.0833333333
All people that live in Africa:
  Grayham Downer
  Judith Brown
  Timothy French
   ...

If you do not see output like this, you will need to resolve the installation problem based on the output you do see.

Running the Mckoi SQL query tool

This step is the one we have been leading up to. Mckoi comes with visual SQL query tool, as shown in Figure 23-2.

Figure 23-2. Mckoi SQL query tool

image

This is a Swing application that allows you to type in SQL queries in the upper window, press the “run” button, and see the results interactively. You can run it on the demo database that comes with mckoi, or on a database that you create. It provides a very good way to learn SQL interactively.

Start the query tool running with these commands:

cd mckoi1.0.2demosimple

java com.mckoi.tools.JDBCQueryTool -url "jdbc:mckoi:local://ExampleDB.conf"
                                          -u user -p "pass1212"

There are two commands there, shown on three lines to fit on this page. You should use this tool to type in the examples in the pages ahead.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144