Vous êtes sur la page 1sur 2

Write MyOwnJDBCProgram.

java using JDBC APIs reflecting the following SQL script as


following:
• Create CD and LOCATION tables
• Insert rows to CD and LOCATION tables
• Display rows of CD and LOCATION tables under column names like Figure presented
below.

create table "LOCATION"


(
"LOCATION_ID" INTEGER NOT NULL PRIMARY KEY,
"LOCATION" VARCHAR(40)
);

create table "CD"


(
"CD_ID" INTEGER NOT NULL PRIMARY KEY,
"TITLE" VARCHAR(40),
"AUTHOR" VARCHAR(40),
"YEAR_CREATED" INTEGER,
"LOCATION" INTEGER,
"RATING" INTEGER,
CONSTRAINT FK_CD_LOCATION FOREIGN KEY (LOCATION) REFERENCES
LOCATION(LOCATION_ID)
);

INSERT INTO LOCATION VALUES (0,'Cha Cha Cha bar');


INSERT INTO LOCATION VALUES (1,'Limon Restaurant');
INSERT INTO LOCATION VALUES (2,'Taqueria el Balazo');
INSERT INTO LOCATION VALUES (3,'Office');
INSERT INTO LOCATION VALUES (4,'Home');

INSERT INTO CD VALUES (


0, 'Rock and Roll Aint Noise Pollution', 'AC/DC', 1980, 0, 9);

INSERT INTO CD VALUES (


1, 'Shake a Leg', 'AC/DC', 1980, 2, 6);

INSERT INTO CD VALUES (


2, 'Have a Drink on Me', 'AC/DC', 1980, 2, 5);

INSERT INTO CD VALUES (


3, 'You Shook Me All Night Long', 'AC/DC', 1980, 1, 8);

INSERT INTO CD VALUES (


4, 'Back in Black', 'AC/DC', 1980, 4, 9);

INSERT INTO CD VALUES (


5, 'Let Me Put My Love into You', 'AC/DC', 1980, 4, 9);