diff --git a/DataBase-and-DataSource.md b/DataBase-and-DataSource.md index fa944d4..7d75f21 100644 --- a/DataBase-and-DataSource.md +++ b/DataBase-and-DataSource.md @@ -37,12 +37,27 @@ Database.connect("jdbc:pgsql://localhost:12346/test", driver = "com.impossibl.po //Gradle compile("com.impossibl.pgjdbc-ng", "pgjdbc-ng", "0.8.3") ``` -* MySQL +* MySQL/MariaDB ```kotlin Database.connect("jdbc:mysql://localhost:3306/test", driver = "com.mysql.jdbc.Driver", user = "root", password = "your_pwd") //Gradle -compile("mysql:mysql-connector-java:5.1.46") +compile("mysql:mysql-connector-java:5.1.48") +``` +* MySQL/MariaDB with latest JDBC driver + Hikari pooling +```kotlin +val config = HikariConfig().apply { + jdbcUrl = "jdbc:mysql://localhost/dbname" + driverClassName = "com.mysql.cj.jdbc.Driver" + username = "username" + password = "secret" + maximumPoolSize = 10 +} +val dataSource = HikariDataSource(config) +Database.connect(dataSource) +// Gradle +implementation "mysql:mysql-connector-java:8.0.19" +implementation "com.zaxxer:HikariCP:3.4.2" ``` * Oracle ```kotlin @@ -57,11 +72,18 @@ Database.connect("jdbc:jdbc:oracle:thin:@//localhost:1521/test", driver = "oracl Database.connect("jdbc:sqlite:/data/data.db", "org.sqlite.JDBC") // In memory Database.connect("jdbc:sqlite:file:test?mode=memory&cache=shared", "org.sqlite.JDBC") +// For both: set SQLite compatible isolation level, see +// https://github.com/JetBrains/Exposed/wiki/FAQ +TransactionManager.manager.defaultIsolationLevel = + Connection.TRANSACTION_SERIALIZABLE + // or Connection.TRANSACTION_READ_UNCOMMITTED //Gradle -compile("org.xerial:sqlite-jdbc:3.21.0.1") +compile("org.xerial:sqlite-jdbc:3.30.1") ``` * H2 ```kotlin +// Database in file, needs full path or relative path starting with ./ +Database.connect("jdbc:h2:./myh2file", "org.h2.Driver") // In memory Database.connect("jdbc:h2:mem:regular", "org.h2.Driver") // In memory / keep alive between connections/transactions @@ -75,4 +97,4 @@ Database.connect("jdbc:sqlserver://localhost:32768;databaseName=test", "com.micr user = "root", password = "your_pwd") //Gradle compile("com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre7") -``` \ No newline at end of file +``` diff --git a/LibDocumentation.md b/LibDocumentation.md index 272fe66..ce09a3d 100644 --- a/LibDocumentation.md +++ b/LibDocumentation.md @@ -86,6 +86,11 @@ Dependencies mapping listed bellow is similar (by functionality) to the previous exposed-jodatime 0.23.1 + + org.jetbrains.exposed + exposed-java-time + 0.23.1 + ``` @@ -97,6 +102,8 @@ dependencies { compile 'org.jetbrains.exposed:exposed-dao:0.23.1' compile 'org.jetbrains.exposed:exposed-jdbc:0.23.1' compile 'org.jetbrains.exposed:exposed-jodatime:0.23.1' + // or + compile 'org.jetbrains.exposed:exposed-java-time:0.23.1' } ``` #### Gradle Kotlin DSL @@ -106,6 +113,19 @@ dependencies { compile("org.jetbrains.exposed", "exposed-dao", "0.23.1") compile("org.jetbrains.exposed", "exposed-jdbc", "0.23.1") compile("org.jetbrains.exposed", "exposed-jodatime", "0.23.1") + // or + compile("org.jetbrains.exposed", "exposed-java-time", "0.23.1") } ``` +### JDBC driver and logging +You also need a JDBC driver for the database system you are using (see [[DataBase and DataSource|DataBase-and-DataSource]]) and a logger for `addLogger(StdOutSqlLogger)`. Example (Gradle syntax): +```kotlin +dependencies { + // for H2 + implementation "com.h2database:h2:1.4.200" + // for logging (StdOutSqlLogger), see + // http://www.slf4j.org/codes.html#StaticLoggerBinder + implementation "org.slf4j:slf4j-nop:1.7.30" +} +```