Skip to content

Commit

Permalink
try fix oracle connection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlauvlwj committed Jan 25, 2023
1 parent f6a20e3 commit f8386fe
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import java.sql.DriverManager
import kotlin.concurrent.thread

abstract class BaseOracleTest : BaseTest() {
lateinit var connection: Connection

override fun init() {
Class.forName(driverClassName)
connection = DriverManager.getConnection(jdbcUrl, username, password)

database = Database.connect(alwaysQuoteIdentifiers = true) {
object : Connection by connection {
override fun close() {
Expand All @@ -23,11 +27,10 @@ abstract class BaseOracleTest : BaseTest() {

override fun destroy() {
execSqlScript("drop-oracle-data.sql")
connection.close()
}

companion object : OracleContainer("zerda/oracle-database:11.2.0.2-xe") {
lateinit var connection: Connection

init {
// At least 1 GB memory is required by Oracle.
withCreateContainerCmdModifier { cmd -> cmd.hostConfig?.withShmSize((1 * 1024 * 1024 * 1024).toLong()) }
Expand All @@ -36,17 +39,5 @@ abstract class BaseOracleTest : BaseTest() {
// Stop the container when the process exits.
Runtime.getRuntime().addShutdownHook(thread(start = false) { stop() })
}

override fun start() {
super.start()

Class.forName(driverClassName)
connection = DriverManager.getConnection(jdbcUrl, username, password)
}

override fun stop() {
connection.close()
super.stop()
}
}
}

0 comments on commit f8386fe

Please sign in to comment.