Getting Set with J2EE - Starting the Database Server
(Page 3 of 4 )
When you install the J2EE 1.4 SDK, a sample database called PointBase is also installed. Well be using this database later on in the book, so we need to ensure that the database is ready for use by starting it and testing it out.
From the Windows Start menu, choose the following option:
Start | All Programs | Sun Microsystems | J2EE 1.4 SDK | Start PointBase
After a second or two you should see a command window with the message:
Server started, listening on port 9092, display level: 0 ...
>
This indicates that the database server has started. The next step is for you to work with the database server from the console of the interactive SQL tool for the PointBase database. To do this, open a new command window and start the PointBase Console by invoking the following command at the command line:
> %J2EE_HOME%\pointbase\tools\serveroption\startconsole.batThe dialog shown below should appear, in which you should select the Open specified Database radio button, and enter the following into the labeled text boxes:
- Driver: com.pointbase.jdbc.jdbcUniversalDriver
- URL: jdbc:pointbase:server://localhost:9092/sun-appserv-samples
- User: PBPUBLIC
- Password: PBPUBLIC
After a second or two you will see the PointBase Console, shown below:

We'll create a database table and test it. Enter the SQL commands shown below into the Enter SQL Commands panel, and click the Execute All icon. Make sure that each line ends with a semicolon, which tells the interactive that the command is complete. These commands create the zootable and insert three rows into it. The results should be similar to what you see in the ExecuteAll tab of the screenshot above.
create table zootable (animal varchar(12) primary key, legcount int);
insert into zootable values ('duck',2); insert into zootable values ('horse',4); insert into zootable values ('aardvark',4);
Now you can run a SQL query to see the data that you've added. Type the following SQL query into the Enter SQL Commands panel, and click the Execute All icon to execute the query:
select * from zootable;
The interactive tool will query the database and print the results of the query:
SQL> select * from zootable;
ANIMAL LEGCOUNT
---------- -----------
duck 2
horse 4
aardvark 4
3 Rows Selected. select * from zoot..., Total 0.391 secs, Compile 0.13 secs
One last step--we want to delete the table before we exit. Type the SQL command, followed by a semicolon, and click the Execute All icon:
drop table zootable;Exit the PointBase Console by choosing Exit from the File menu.
When you are finished with PointBase, you can stop it by choosing the following option from the Start menu:
Start | All Programs | Sun Microsystems | J2EE 1.4 SDK | Stop PointBase
Next: Starting the J2EE Server >>
More Java Articles
More By Apress Publishing
|
This article is excerpted from chapter two of the book Beginning J2EE 1.4 From Novice to Professional, written by James L. Weaver, Kevin Mukhar, and Jim Crume (Apress, 2005; ISBN: 1590593413). Check it out at your favorite bookstore today. Buy this book now.
|
|