ORA-02396: exceeded maximum idle time with scalike jdbc 3.3.5

45 views
Skip to first unread message

Marcelo Valle

unread,
Aug 27, 2019, 5:56:08 AM8/27/19
to ScalikeJDBC Users Group
Hi all,

My application executes a DB operation, then it executes a shell command that takes minutes, and then other db operation. This is done in a loop. 

When my shell command takes too long, I get the following error from executing a simple update:

```
19/08/24 15:08:25 ERROR StatementExecutor$$anon$1: SQL execution failed (Reason: ORA-02396: exceeded maximum idle time, please connect again
```

I am using oracle jdbc thin driver and this is how I am using the db in my app:

```

class OracleClient(val jdbcClassName: String, jdbcUrl: String, jdbcUser: String, jdbcPasswd: String) {
ConnectionPool.singleton(jdbcUrl, jdbcUser, jdbcPasswd) // default settings

implicit val session: DBSession = AutoSession

private def updateUfDateColumn(ufId: String, columnName: String): Unit = {
val currentDateTime = new Timestamp(System.currentTimeMillis())
val targetDate = FullDateFormat.format(currentDateTime.toLocalDateTime)
logger.info(s"Updating UF row '$ufId', setting $columnName to '$targetDate'")
val query =
s"""UPDATE USAGE_FILES set $columnName=TO_TIMESTAMP('$targetDate', 'YYYY-MM-DD HH24:MI:SS')
|where ID = '${ufId}'""".stripMargin
val result = SQL(query).update.apply()
logger.info(s"UF UPDATE: $result records affected for $ufId")
}
}
```

Thie update fails when the idle time between 2 updates is too long. 

Question: is there a way to set the connection pool to auto reconnect in these cases? Any thing I could easily change in my code to avoid getting this problem again? 

Thanks,
Marcelo.

Reply all
Reply to author
Forward
0 new messages