-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainWithH2.kt
32 lines (22 loc) · 911 Bytes
/
MainWithH2.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package nl.toefel.blog.exposed
import nl.toefel.blog.exposed.rest.Router
import org.jetbrains.exposed.sql.Database
import org.slf4j.Logger
import org.slf4j.LoggerFactory
/**
* Starts an in-memory H2 database, creates the schema and loads some test data
*/
class MainWithH2 {
companion object {
private val logger: Logger = LoggerFactory.getLogger(MainWithH2::class.java)
val h2ConnectionString = "jdbc:h2:mem:regular;DB_CLOSE_DELAY=-1;"
@JvmStatic
fun main(args: Array<String>) {
logger.info("H2 database connection string: $h2ConnectionString")
val db = Database.connect(h2ConnectionString, driver = "org.h2.Driver")
db.useNestedTransactions = true // see https://github.com/JetBrains/Exposed/issues/605
DatabaseInitializer.createSchemaAndTestData()
Router(8080).start().printHints()
}
}
}