Running the Example Code

The next step is to try running 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 file in the jrelibext directory):

java  SimpleApplicationDemo

If all is well, you will see some sample output similar to this, 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 debug the problem based on the output you do see. After you have the database example running, go to Connecting to the Database on page 615,to see how your Java application code establishes a connection with a database prior to sending across various SQL commands. We will finish up this section by saying a few words about the evolution of the JDBC.

JDBC was originally an acronym for “Java Data Base Connectivity,” and is now held by Sun marketing not to be an acronym at all. JDBC was developed independently of the JDK, and first bundled with it in JDK 1.1. The package name is java.sql. Your database code may also use the java.math package that supports arbitrary-precision arithmetic. JDBC development continued to add more advanced features, creating JDBC version 2.0. Part of the JDBC 2.0 library was bundled with Java 2 (the release that is also known as JDK 1.2), and part of it was not. Table 24-3 summarizes the situation.

Table 24-3. JDBC versions

JDBC version

Bundled with

Package name

Contents

JDBC 1.0 (previously called 1.2)

JDK 1.1

java.sql

Basic Java client to database connectivity.

JDBC 2.0 core API

JDK 1.2 and later

java.sql

Added features such as scrollable results sets, batch updates, new datatypes for SQL-3, and programmatic updates using the result set.

JDBC 2.0 optional API

J2EE 1.2 and later

javax.sql

Can be downloaded from java.sun.com/products/jdbc/. Contains database server-side functionality. Prepares the ground for the use of database-aware Java beans.

JDBC 2.1 optional API

Not bundled

javax.sql

Incremental improvement and additions over the 2.0 API.

JDBC 3.0 core API

JDK 1.4 and later

java.sql

Adds support for connection pooling, statement pooling, and a migration path to the Connector Architecture.

The Mckoi database manager implements the JDBC 2.0 core API.

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

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