Don't fail if the DB doesn't exist yet
This commit is contained in:
parent
ec65d9da48
commit
1d1c40fe30
2 changed files with 6 additions and 1 deletions
|
|
@ -112,6 +112,12 @@ public class UserResource {
|
|||
private int getUserCount() throws SQLException {
|
||||
try (Connection connection = ds.getConnection()) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
try (ResultSet rs = statement.executeQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='users'")) {
|
||||
if (!rs.next()) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
try (ResultSet rs = statement.executeQuery("SELECT COUNT(1) FROM users")) {
|
||||
rs.next();
|
||||
return rs.getInt(1);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
quarkus.datasource.db-kind=sqlite
|
||||
quarkus.datasource.autoCommit=false
|
||||
#quarkus.datasource.jdbc.url=jdbc:sqlite::memory:
|
||||
quarkus.datasource.jdbc.url=jdbc:sqlite:sample.db
|
||||
quarkus.hibernate-orm.database.generation=none
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue