Skip to content

Commit f8386fe

Browse files
try fix oracle connection issue
1 parent f6a20e3 commit f8386fe

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

ktorm-support-oracle/src/test/kotlin/org/ktorm/support/oracle/BaseOracleTest.kt

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import java.sql.DriverManager
88
import kotlin.concurrent.thread
99

1010
abstract class BaseOracleTest : BaseTest() {
11+
lateinit var connection: Connection
1112

1213
override fun init() {
14+
Class.forName(driverClassName)
15+
connection = DriverManager.getConnection(jdbcUrl, username, password)
16+
1317
database = Database.connect(alwaysQuoteIdentifiers = true) {
1418
object : Connection by connection {
1519
override fun close() {
@@ -23,11 +27,10 @@ abstract class BaseOracleTest : BaseTest() {
2327

2428
override fun destroy() {
2529
execSqlScript("drop-oracle-data.sql")
30+
connection.close()
2631
}
2732

2833
companion object : OracleContainer("zerda/oracle-database:11.2.0.2-xe") {
29-
lateinit var connection: Connection
30-
3134
init {
3235
// At least 1 GB memory is required by Oracle.
3336
withCreateContainerCmdModifier { cmd -> cmd.hostConfig?.withShmSize((1 * 1024 * 1024 * 1024).toLong()) }
@@ -36,17 +39,5 @@ abstract class BaseOracleTest : BaseTest() {
3639
// Stop the container when the process exits.
3740
Runtime.getRuntime().addShutdownHook(thread(start = false) { stop() })
3841
}
39-
40-
override fun start() {
41-
super.start()
42-
43-
Class.forName(driverClassName)
44-
connection = DriverManager.getConnection(jdbcUrl, username, password)
45-
}
46-
47-
override fun stop() {
48-
connection.close()
49-
super.stop()
50-
}
5142
}
5243
}

0 commit comments

Comments
 (0)