https://kotlinlang.org logo
#exposed
Title
# exposed
w

wouterdoeland

01/19/2018, 4:49 PM
Why is this throwing a
JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL)
while close on exit = false is already set?
Copy code
@Before
    fun setupDatabase() {
        Database.connect("jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1", "org.h2.Driver")

        // create tables
    }

    @After
    fun tearDownDatabase() {
        transaction {
            exec("SHUTDOWN;")
        }
    }
t

tapac

01/19/2018, 5:37 PM
I'm not sure that you need
DB_CLOSE_ON_EXIT=FALSE
if you running tests (if it tests ofc) within single run. I use same approach here : https://github.com/JetBrains/Exposed/blob/6c80f309d4409cadfd1540494683a7a197a4ab08/src/test/kotlin/org/jetbrains/exposed/sql/tests/h2/MultiDatabaseTest.kt
w

wouterdoeland

01/20/2018, 10:23 AM
I want to test my application that uses many
transaction
blocks, how should I do that? I thought setting the close delay to -1 would work, but it doesn't?
t

tapac

01/21/2018, 3:51 PM
I think that`tearDownDatabase` executes on evert Test function and shutdown closes db after first one. Try to remove
after
block
5 Views