Search code examples
databaseconnectiontimeoutsorm

How to set a timeout to the database connection in SORM?


I use H2 database in embedded mode with SORM. If the database is busy then SORM just continue to wait. There are no exception, nothing happens. This is misleading. :( So how i can set the db connection timeout?


Solution

  • How come it's misleading and how come exceptions are better? If you need the process to be non-blocking just use Future like so:

    future{ Db.query[Artist].fetch() }.foreach{ artists => ... }
    

    Consider this to be a non-blocking version of the following:

    val artists = Db.query[Artist].fetch()