-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbank.java
More file actions
43 lines (37 loc) · 1.49 KB
/
bank.java
File metadata and controls
43 lines (37 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.sql.*;
public class bank {
public static void main(String[] args) {
try {
//Connect to server
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
System.out.println("Connecting to JDBC...");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","fedora","oracle")
System.out.println("JDBC connected.\n");
//Create tables
Statement stmt = conn.createStatement();
stmt.execute("create table branch( "+
"numb varchar(3) NOT NULL Primary Key, "+
"addy varchar(10) NOT NULL)");
stmt.execute("create table customer( "+
"numb varchar(5) NOT NULL Primary Key, "+
"name varchar(10) NOT NULL unique, "+
"status int NOT NULL)");
stmt.execute("create table account( "+
"numb varchar(7) NOT NULL Primary Key, "+
"c_numb varchar(5) NOT NULL,"+
"balance int NOT NULL,"+
"foreign key (c_numb) references customer(numb) ON DELETE CASCADE)");
System.out.println("Tables created.");
stmt.close();
conn.close();
}
catch(Exception e)
{
System.out.println("SQL exception: ");
e.printStackTrace();
System.exit(-1);
}
}
}