fixed database creation
This commit is contained in:
parent
388459b6a2
commit
07fa6d09a4
|
@ -43,6 +43,7 @@ public class Database {
|
|||
assert connection != null;
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(getClass().getClassLoader().getResource("database.sql").getFile()))) {
|
||||
for (String line = br.readLine(); line != null; line = br.readLine()) {
|
||||
System.out.println(line);
|
||||
PreparedStatement statement = connection.prepareStatement(line);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS test(id bigint, primary key auto_increment, hello varchar(25));
|
||||
CREATE TABLE IF NOT EXISTS test(id bigint primary key auto_increment, hello varchar(25));
|
||||
INSERT IGNORE INTO test(hello) values ('Welt');
|
||||
CREATE TABLE IF NOT EXISTS book (id bigint primary key auto_increment, title varchar(50), description varchar(500) unique , price int, year year, publisher bigint, category bigint, image varchar(11) unique);
|
||||
CREATE TABLE IF NOT EXISTS book (id bigint primary key auto_increment, title varchar(50), description varchar(500), price int, year year, publisher bigint, category bigint, image varchar(11) unique);
|
||||
CREATE TABLE IF NOT EXISTS publisher(id bigint primary key auto_increment, name varchar(50) unique);
|
||||
CREATE TABLE IF NOT EXISTS author(id bigint primary key auto_increment, name varchar(50) unique);
|
||||
CREATE TABLE IF NOT EXISTS author_book(author bigint, book bigint, primary key(author, book), foreign key (author) REFERENCES author(id), foreign key (book) references book(id));
|
||||
|
|
Loading…
Reference in New Issue