Skip to content

Commit 8cf5dce

Browse files
committed
use multiline SQL string
1 parent 648a6d5 commit 8cf5dce

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

2-0-jdbc-api/2-0-2-create-table/src/main/java/com/bobocode/AccountDbInitializer.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,20 @@ public AccountDbInitializer(DataSource dataSource) {
3232
public void init() throws SQLException {
3333
try (Connection connection = dataSource.getConnection()) {
3434
Statement statement = connection.createStatement();
35-
statement.execute("CREATE TABLE account(" +
36-
"id BIGINT," +
37-
" email VARCHAR(255) NOT NULL," +
38-
" first_name VARCHAR(255) NOT NULL," +
39-
" last_name VARCHAR(255) NOT NULL," +
40-
" gender VARCHAR(255) NOT NULL," +
41-
" birthday DATE NOT NULL," +
42-
" balance DECIMAL(19,4)," +
43-
" creation_time TIMESTAMP NOT NULL DEFAULT now()," +
44-
" CONSTRAINT account_pk PRIMARY KEY (id)," +
45-
" CONSTRAINT account_email_uq UNIQUE (email)" +
46-
");");
35+
statement.execute("""
36+
CREATE TABLE account(
37+
id BIGINT,
38+
email VARCHAR(255) NOT NULL,
39+
first_name VARCHAR(255) NOT NULL,
40+
last_name VARCHAR(255) NOT NULL,
41+
gender VARCHAR(255) NOT NULL,
42+
birthday DATE NOT NULL,
43+
balance DECIMAL(19,4),
44+
creation_time TIMESTAMP NOT NULL DEFAULT now(),
45+
CONSTRAINT account_pk PRIMARY KEY (id),
46+
CONSTRAINT account_email_uq UNIQUE (email)
47+
);
48+
""");
4749
}
4850
}
4951
}

0 commit comments

Comments
 (0)