If you are going to try just one DBMS, I suggest you initially try PostgreSQL,
principally because it comes with most major Linux distributions and may already
be installed on your system.
PostgreSQL is a sophisticated Object-Relational DBMS, supporting almost
all SQL constructs, including subselects, transactions, and user-defined types
and functions. It is the most advanced open-source database available anywhere.
Commercial Support is also available from PostgreSQL, Inc. The current version
is 6.5.3 and is available at any of the many mirror sites or on CD. (From
the PostgreSQL website.)
PostgreSQL may have already been shipped with your Linux distribution because
of its open source license.
Download and Installation
Rather than downloading from PostgreSQL, I suggest you initially try the
PostgreSQL that most likely came with your Linux distribution.
To confirm that PostgreSQL is installed on your computer, type:
rpm -qa | grep postgresql
or
which postmaster
which psql
You need the postgresql, postgresql-server, and postgresql-java packages
installed to use Java with PostgreSQL.
Make sure PostgreSQL is running. Type:
ps -f -u postgres
You should see postmaster, the PostgreSQL daemon, running.
If postmaster is not running, there will probably be a Sys V Init script
that you can use to start it. In many distributions it is located in /etc/rc.d/init.d.
To start PostgreSQL, type:
cd /etc/rc.d/init.d
./postgresql start
You can use the above "ps" command to confirm that PostgreSQL
is running.
Note: To use JDBC, PostgreSQL needs to have been started with the '-i'
parameter indicating support for TCP/IP connections rather than solely UNIX
domain sockets. Confirm that postmaster> was started with the '-i' paramter.
Create a test database by typing:
su - postgres
createdb javatest
You should see no error messages.
Create a test table with one test row. First, log in to the interactive
PostgreSQL tool and connect to the javatest database you just created by typing
(as the postgres user):
psql javatest
You should see confirmation that you are connected to the database: javatest.
Then, create the test table by typing (within psql):
create table test (col1 varchar(255));
You should see the "CREATE" confirmation message.
Next, insert one row by typing (within psql):
insert into test (col1) values ('Hello, from PostgreSQL!');
You should see the "INSERT" confirmation message.
Finally, confirm that the row is there by typing (within psql):
select col1 from test;
You should see the row you just created.
You can exit psql by typing "\ q".
For more assistance on working with PostgreSQL, I suggest you look into
the Database-SQL-RDBMS HOW-TO document for Linux (PostgreSQL Object Relational
Database System) at
http://metalab.unc.edu/mdw/HOWTO/PostgreSQL-HOWTO.html.
You will need to add the appropriate JAR to your CLASSPATH. The PostgreSQL
JARs come in the postgresql-jdbc package.
Sybase Adaptive Server Enterprise is a commericial RDBMS that is available
for the Linux operating system. While Sybase has recently released version
12.0, version 11.9.2 is available for Linux.
According to the Sybase website, "By porting ASE to Linux, Sybase
provides the Linux development community with the first highly scalable, high-performance
database engine available for the platform. The package includes the standard
features of Adaptive Server Enterprise and all related connectivity components.
Adaptive Server Enterprise 11.9.2 is offered FREE for development."
If you have access to a Sybase server on the network, you only need to
download and install the JDBC driver.
Installation
Installation of Sybase is beyond the scope of this HOWTO. This HOWTO will
assume that Sybase has been correctly installed and configured and that you
can get to Sybase using isql.
Log into isql as sa and create a test user and test database by typing:
create database javatest
go
sp_addlogin javatest, javatest, javatest
go
use javatest
go
sp_dbowner javatest
go
You should see no error messages.
Create a test table with one test row. First, log in to isql as the javatest
user and type:
create table test (col1 varchar(255))
go
You should see no error messages.
Next, insert one row by typing:
insert into test (col1) values ('Hello, from Sybase!')
go
You should see no error messages.
Finally, confirm that the row is there by typing:
select col1 from test
go
You should see the row you just created.
You can exit isql by typing "exit".
For more assistance on working with Sybase, review the documentation that
can be downloaded with Sybase.
You will need to add the appropriate JAR to your CLASSPATH.
You will need to substitute the host and port number of you Sybase server
as appropriate. See $SYBASE/interfaces and the $DSQUERY entry
for what values to use for the host and port number.
Compile the program with the Java compiler.
javac SybaseTest.java
If the compiler produces errors, double check the syntax and confirm your
PATH and CLASSPATH.
Run the program with the JVM.
java SybaseTest
If the JVM produces errors, confirm your PATH and CLASSPATH.
You should see the following output:
Hello, from Sybase!
Congratulations, you have installed, set up an environment for, and tested
a JDBC interface to Sybase.