How to use JDBC

 
 
Before explaining how to use JDBC you should understand the following terms:

Database
A database contains a collection of data structured in a way that information can be retrieved from it.

DBMS
DBMS is software that stores and retrieves the information in the database.

Java DataBase Connectivity (JDBC)
JDBC is a Java API which is used to manipulate relational databases. The set of core classes that form the JDBC API can be found in the java.sql package.

Metadata
A database also contains information about the data it stores and how it is organized. This information is called metadata.

Structured Query Language (SQL)
SQL is the standard language to manipulate relational databases.

JDBC driver
A JDBC driver is a class which implements the JDBC driver interface. There a four JDBC driver types:
  1. JDBC-ODBC bridge + ODBC driver
  2. Native-API partly-Java driver
  3. JDBC-Net pure Java driver
  4. native-protocol pure Java driver








SQL commands.



Information
none

Operating system used
Windows XP Home Edition Version 5.1 SP 2

Software prerequisites
Cloudscape

Procedure
  1. Create a database:

    CREATE TABLE <table name> (<column element>) [, <column element>]..)

    A <column element> is:
    <column name> <data type> [DEFAULT <expression>]
    [<column constraint> [, <column constraint>]...]

    A <column constraint> is:
    PRIMARY KEY | NOT NULL | UNIQUE


  2. Delete a database:

    DROP TABLE <table name>

  3. Read database values:

    SELECT [ALL | DISTINCT] <select list>
    FROM <table reference list>
    WHERE <search condition list>
    [ORDER BY <column designator> [ASC | DESC]
    [, <column designator> [ASC | DESC]]...]

    <select list> is a comma separated list of column names or "*"
    if all values should be displayed.




  4. Insert database values:

    INSERT INTO <table name>
    [(<column name> [, <column name>]...)]
    VALUES (<expression> [, <expression>]...)


  5. Update database values:

    UPDATE <table name>
    SET <column name> = {<expression> | NULL}
    [, <column name> = {<expression> | NULL}]...
    WHERE <search condition>


  6. Delete a table:

    DELETE FROM <table name>
    WHERE <search condition>