Commit 7d40c0fc authored by srosse's avatar srosse
Browse files

OO-4829: update MySQL driver to last 8.0.21 version

parent 8863e18b
......@@ -85,6 +85,8 @@ section below.
#### 2. Setting up the database
Prepare database permissions and initialize the database.
*For PostgreSQL*: please check their PostgreSQL manual how to create a user and database.
*For MySQL*: create a user 'openolat' and a database 'openolat'
......@@ -95,7 +97,11 @@ UPDATE mysql.user SET HOST='localhost' WHERE USER='openolat' AND HOST='%';
FLUSH PRIVILEGES;
```
*For PostgreSQL*: please check their PostgreSQL manual how to create a user and database.
The time zone needs to be set if you don't already defined it.
```sql
SET GLOBAL time_zone = 'Europe/Zurich';
```
Write the OpenOlat database schema to the OpenOlat database. Example for MySQL:
......@@ -137,7 +143,7 @@ arguments to the VM arguments:
Open the generated server.xml file and manually set the following parameters:
* In the "Context" element set parameter reloadable="false"
* In all "Connector" elements set paramter URIEncoding="UTF-8"
* In all "Connector" elements set parameter URIEncoding="UTF-8"
Option: to use the application server database connection pool configure a jdbc data
resource in the "Context" element, set db.source=jndi in the olat.local.properties with
......@@ -153,7 +159,7 @@ Next add the resource descriptor to your tomcat context descriptor.
*For MySQL:*
```xml
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" type="javax.sql.DataSource"
<Resource auth="Container" driverClassName="com.mysql.cj.jdbc.Driver" type="javax.sql.DataSource"
maxIdle="4" maxTotal="16" maxWaitMillis="10000"
name="jdbc/OpenOLATDS"
password="olat" username="olat"
......
......@@ -34,7 +34,7 @@ db.user=openolat
# the password of the OLAT database user
db.pass=openolat
# JDBC options (e.g., to set character channel behavior etc.)
db.jdbc.options=useUnicode=true&amp;characterEncoding=UTF-8
db.jdbc.options=?characterEncoding=UTF-8&connectionCollation=utf8_unicode_ci
########################################################################
# Web application container (e.g., Tomcat) settings
......
......@@ -71,7 +71,7 @@
<io.jsonwebtoken>0.10.7</io.jsonwebtoken>
<io.undertow>2.1.3.Final</io.undertow>
<jackson.version>2.11.1</jackson.version>
<org.mysql.version>5.1.46</org.mysql.version>
<org.mysql.version>8.0.21</org.mysql.version>
<org.postgresql.version>42.2.14</org.postgresql.version>
<org.infinispan.version>11.0.1.Final</org.infinispan.version>
<lucene.version>7.7.0</lucene.version>
......@@ -745,7 +745,7 @@
<!-- common configuration shared by all executions -->
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<driver>com.mysql.cj.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:${test.env.db.host.port}/${test.env.db.name}</url>
<username>${test.env.db.user}</username>
<password>${test.env.db.pass}</password>
......
......@@ -24,6 +24,7 @@
*/
package org.olat.core.commons.persistence;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
......@@ -60,37 +61,30 @@ public class InnoDBAwareDriverManagerDataSource extends DriverManagerDataSource
if (!dbVendor.contains("mysql")) {
return;
}
Statement statement = null;
try {
try(Connection connection = getConnection();
Statement statement = connection.createStatement()) {
log.info(Tracing.M_AUDIT, "Checking whether mysql tables support transactions based on innoDB tab...");
statement = this.getConnection().createStatement();
statement.execute("show create table o_plock;");
ResultSet result = statement.getResultSet();
result.first();
String createTableCommand = result.getString("Create Table");
if (createTableCommand.contains("InnoDB")) {
log.info(Tracing.M_AUDIT, "Your mysql tables look like they support transactions, fine!");
if(result.next()) {
String createTableCommand = result.getString("Create Table");
if (createTableCommand.contains("InnoDB")) {
log.info(Tracing.M_AUDIT, "Your mysql tables look like they support transactions, fine!");
} else {
throw new StartupException("Your tables do not support transactions based on innoDB tables. Check your database server and enable innoDB engine! Your table currently runs: " + createTableCommand);
}
} else {
throw new StartupException("Your tables do not support transactions based on innoDB tables. Check your database server and enable innoDB engine! Your table currently runs: "+createTableCommand);
throw new StartupException("Cannot retrieve table informations.");
}
result.close();
} catch (SQLException e) {
if (e.getMessage().contains("doesn't exist")) {
log.info(Tracing.M_AUDIT, "o_plock table does not yet exist, will check transaction support on next startup");
} else {
throw new StartupException("Could not execute db statement.", e);
}
} finally {
try {
if (statement != null) {
statement.close();
}
} catch (SQLException e2){
log.warn("Could not close sql statement", e2);
throw new StartupException("Could not close sql statements.", e2);
}
}
}
......
......@@ -25,7 +25,7 @@
<constructor-arg>
<props>
<!-- Using datasource of hibernate -->
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</prop>
<prop key="hibernate.connection.url">jdbc:mysql://${db.host}:${db.host.port}/${db.name}${db.url.options.mysql}</prop>
<prop key="hibernate.connection.username">${db.user}</prop>
<prop key="hibernate.connection.password">${db.pass}</prop>
......@@ -192,8 +192,8 @@
<!-- The mysql datasource checks upon startup whether the tables are of type InnoDB, if not it will not start. If you have an other type of transactional tables just switch back the spring config
to the normal org.springframework.jdbc.datasource.DriverManagerDataSource and the check is gone.-->
<bean id="mysql_local_DataSource" class="org.olat.core.commons.persistence.InnoDBAwareDriverManagerDataSource" lazy-init="true" init-method="init">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}?useUnicode=true&amp;characterEncoding=UTF-8</value></property>
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver" />
<property name="url"><value>jdbc:mysql://${db.host}:${db.host.port}/${db.name}${db.url.options.mysql}</value></property>
<property name="username" value="${db.user}" />
<property name="password" value="${db.pass}" />
<property name="dbVendor" value="${db.vendor}" />
......
......@@ -696,11 +696,9 @@ db.pass=olat
#this option is currently only for oracle
db.default.schema=olat
# Special options for mysql database. Set useOldUTF8Behavior=true if
# your mysql database is setup up with iso-latin (or any other) encoding.
# Remove the useOldUTF8Behavior parameter if you use native UTF-8 on the
# database (recommended when setting up a new system)
db.url.options.mysql=?useUnicode=true&characterEncoding=UTF-8
# Special options for mysql database. It's important to set the
# attribute connectionCollation according your database collation
db.url.options.mysql=?characterEncoding=UTF-8&connectionCollation=utf8_unicode_ci
# enable database debugging (seldom required except for developers)
db.show_sql=false
......
......@@ -46,6 +46,7 @@ db.name=${test.env.db.name:olattest}
db.user=${test.env.db.user:olat}
db.pass=${test.env.db.pass:olat}
db.host.port=${test.env.db.host.port:3306}
db.url.options.mysql=?characterEncoding=UTF-8&connectionCollation=utf8mb4_unicode_ci
auto.upgrade.database=false
db.hibernate.hikari.leakDetectionThreshold=120000
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment