Skip to content

Commit e1dd6f5

Browse files
Revert "try fix oracle connection issue"
This reverts commit f8386fe.
1 parent f8386fe commit e1dd6f5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

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

1010
abstract class BaseOracleTest : BaseTest() {
11-
lateinit var connection: Connection
1211

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

2824
override fun destroy() {
2925
execSqlScript("drop-oracle-data.sql")
30-
connection.close()
3126
}
3227

3328
companion object : OracleContainer("zerda/oracle-database:11.2.0.2-xe") {
29+
lateinit var connection: Connection
30+
3431
init {
3532
// At least 1 GB memory is required by Oracle.
3633
withCreateContainerCmdModifier { cmd -> cmd.hostConfig?.withShmSize((1 * 1024 * 1024 * 1024).toLong()) }
@@ -39,5 +36,17 @@ abstract class BaseOracleTest : BaseTest() {
3936
// Stop the container when the process exits.
4037
Runtime.getRuntime().addShutdownHook(thread(start = false) { stop() })
4138
}
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+
}
4251
}
4352
}

0 commit comments

Comments
 (0)