// Use this program as follows:

// java CreateTableUB <oracle user name> <password>

// where <oracle user name> is same as UNIX user name at UB

// Program IS Operational AS OF 12/5/2000

import java.sql.*;

public class CreateTableUB {

public static void main(String args[]) {

try {

// load the Oracle driver class

Class.forName ("oracle.jdbc.driver.OracleDriver");

new CreateTableUB(args[0], args[1]); }

catch (ClassNotFoundException e) {

System.out.println(e); } }

public CreateTableUB(String user, String password) {

try {

// open the connection with host, port,dbname, user access & password

Connection dbConnect = DriverManager.getConnection(

"jdbc:oracle:thin:"+ "@cpe.bridgeport.edu:1521:csdb",user , password);

//Create a Statement

Statement select = dbConnect.createStatement();

// Execute the create statement

ResultSet results = select.executeQuery

("CREATE TABLE studentTable " +

"(student_id VARCHAR(8) NOT NULL, " +

" name VARCHAR(30), " +

" age INTEGER CHECK (age>=0 and age<99), " +

" subject VARCHAR(7), " +

" PRIMARY KEY(student_id))" );

System.out.println("Create table completed!");

select.close();

dbConnect.close(); }

catch (SQLException e) {

System.out.println(e); } } }