CSC 309 Pointbase Tutorial

Timothy Fowler (based on slides by Nan Niu) http://www.cdf.toronto.edu/~radu/csc309/guide/pointbase.html

July 2, 2008 Overview

What is PointBase and how does it fit into the rest of the framework?

A few simple examples

Questions

2 What is PointBase? PointBase is an RDBMS – An RDBMS is a relational management system – Other RDBMSs include MySQL and the Oracle RDBMS Pointbase fully supports JDBC 1.x API, and adheres to ANSI and ISO standards

3 How does PointBase fit in?

• Java classes will use the java.sql.* to interact with PointBase • JDBC is a standard database interface that conveys commands to PointBase behind the scenes

4 PointBase Commander and Console PointBase allows users to interact with manually in two ways: – CLI: PointBase Commander – GUI: PointBase Console

Create a pointbase.ini file for configuring your database Begin with the sample ini file available from the course website database.home = HOME_DIRECTORY/csc309/pointbase/

5 Creating a database

Start one of the database management tools – setenv CLASSPATH “.:/h/u2/csc309h/lib/pointbase/pbembedded41ev.jar:/h/u2/ csc309h/lib/pointbase/pbtools41ev.jar” – java com.pointbase.tools.toolsConsole – java com.pointbase.tools.toolsCommander Create a sample database – select * from systables; – create student (id integer, name character (40), birthday date); – insert into student values (1, 'John', date '1980-1-1');

6 Commit and Autocommit

After making changes to a PointBase database, these changes must be committed – This can be done using the “commit;” command – This can also be done by turning on autocommit by executing “set autocommit on;” • By default: Commander has autocommit off Console has autocommit on

7 Simple Examples

DBTest – Demonstrates a simple way to check that the DB is working. Program prints the names of all tables in the DB.

DBTable – Demonstrates how to add/delete tables and how to insert/query data.

DBInteractive – Interactive program that demonstrates how to add/delete tables and how to insert/query data.

8 Things to note

A lock file is used to stop concurrent modification – If you have problems starting Commander after a crash, try deleting “.lck” file Quotation marks (e.g., “, \”, ‘, etc.) when handling character/string type fields Remember to “commit;” or turn on autocommit Remember to close SQL statement and DB connection at the end Remember to set your CLASSPATH If you don't know where to start, begin with the

3 demo files from the course website 9