Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions study/src/main/java/transaction/DatabasePopulatorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.sql.DataSource;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.sql.Connection;
import java.sql.SQLException;
Expand All @@ -20,12 +21,12 @@ public static void execute(final DataSource dataSource) {
Statement statement = null;
try {
final var url = DatabasePopulatorUtils.class.getClassLoader().getResource("schema.sql");
final var file = new File(url.getFile());
final var file = new File(url.toURI());
final var sql = Files.readString(file.toPath());
connection = dataSource.getConnection();
statement = connection.createStatement();
statement.execute(sql);
} catch (NullPointerException | IOException | SQLException e) {
} catch (NullPointerException | IOException | SQLException | URISyntaxException e) {
log.error(e.getMessage(), e.getCause());
} finally {
try {
Expand Down