From a3343329c9fefe53cd9888f228e33ca293b53489 Mon Sep 17 00:00:00 2001 From: Miguel Reboiro Jato Date: Sat, 17 Oct 2020 19:20:08 +0200 Subject: [PATCH] Updates to MySQL 8+ The project has been updated so that it now supports MySQL 8+ databases. --- README.md | 82 +++++++++---------- .../wildfly/v10.1.0/standalone.xml | 5 +- .../wildfly/v8.2.1/standalone.xml | 5 +- pom.xml | 6 +- 4 files changed, 47 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index e72b7ee..b4546d7 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ This repository contains the code base of a sample project that will be used in the XCS subject inside the DGSS itinerary. ## 1. Deployment Environment -The environment is based on Java 8, Maven 3.3+, Git 1.9+, MySQL 5.5+, -WildFly 10.1.0 and Eclipse Oxygen for JavaEE. +The environment is based on Java 8, Maven 3.3+, Git 1.9+, MySQL 8+, +WildFly 10.1.0 and Eclipse for JavaEE. ### 1.1. Java JDK 8 Download and install Java JDK 8, preferably the Oracle version (the commands @@ -51,7 +51,7 @@ Once Git is installed in your system, clone the project: git clone http://sing-group.org/dt/gitlab/dgss-2021/xcs-sample.git ``` -### 1.4. MySQL 5.5+ +### 1.4. MySQL 8+ In order to run the tests with the `wildfly-embedded-mysql` profile (more about this in the **Sample 2** section) and to run the application, we need a MySQL server. @@ -66,11 +66,12 @@ commands: ```sql CREATE DATABASE xcs; -GRANT ALL PRIVILEGES ON xcs.* TO xcs@localhost IDENTIFIED BY 'xcs'; -FLUSH PRIVILEGES; - CREATE DATABASE xcssampletest; -GRANT ALL PRIVILEGES ON xcssampletest.* TO xcs@localhost IDENTIFIED BY 'xcs'; + +CREATE USER xcs@'%' IDENTIFIED BY 'xcs'; + +GRANT ALL PRIVILEGES ON xcs.* TO xcs@'%'; +GRANT ALL PRIVILEGES ON xcssampletest.* TO xcs@'%'; FLUSH PRIVILEGES; ``` @@ -119,8 +120,8 @@ VALUES ('CAT','2000-01-01 01:01:01','Pepecat','pepe'), You can find the `xcs-sample-mysql.sql` and `xcs-sample-test-mysql.sql` scripts with these queries stored in the `additional-material/db` project folder. -### 1.5. Eclipse Oxygen for Java EE -Open Eclipse Oxygen for Java EE and import your Maven project with +### 1.5. Eclipse for Java EE +Open Eclipse for Java EE and import your Maven project with `File -> Import -> Maven -> Existing Maven Projects`. In the dialog opened you have to select as `Root directory` the directory of the project that you have just cloned (it should contain a `pom.xml` file). @@ -134,7 +135,7 @@ advanced settings of the dialog and use a custom `Name template` (for example, If you want, you can use any other IDE, such as IntelliJ IDEA or NetBeans, as long as they are compatible with Maven projects, but we recommend using Eclipse -Oxygen for Java EE. +for Java EE. ### 1.6 WildFly 10.1.0 If you want to run the project you need a Java EE server. In this section you @@ -156,21 +157,18 @@ file of the server. To do so, you have to edit this file and add the following content to the `` element: ```xml - - jdbc:mysql://localhost:3306/xcs - mysql-connector-java-5.1.21.jar - - 30 - - - xcs - xcs - + + jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe%2FMadrid + mysql-connector-java-8.0.21.jar + + xcs + xcs + ``` In addition, you also have to add the MySQL driver to the deployments folder -(`standalone/deployments`). You can download it form [here](http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar) +(`standalone/deployments`). You can download it form [here](http://central.maven.org/maven2/mysql/mysql-connector-java/8.0.21/mysql-connector-java-8.0.21.jar) to the deployments (`standalone/deployments`) directory and WildFly will automatically deploy it on startup. @@ -182,9 +180,9 @@ Inside the `` element you have to add a new security realm: ```xml - - - + + + ``` @@ -193,23 +191,23 @@ security domains: ```xml - - - - - + + + + + - - - - - - - - - - + + + + + + + + + + ``` @@ -239,7 +237,7 @@ This will launch the construction of the project and, at the end, the EAR will be deployed. Remember that, if you want a fast deployment, you can avoid the test execution with the parameter `-DskipTests=true`. -#### 1.7. Running the application from Maven +#### 1.7. Running the application from Maven (Recommended) This project includes the Maven WildFly plugin, which allows the execution of the application without needing an external WildFly server. To run the application with the running MySQL database (`xcs`) you just have execute the @@ -336,7 +334,7 @@ configuration will work for the current configuration: This configuration will run with the **H2** database. If you wish to run the tests with the **MySQL** database, you have to add to additional system configuration: -* `mysql.version`: The version of the MySQL driver (currently, `5.1.21`). +* `mysql.version`: The version of the MySQL driver (currently, `8.0.21`). * `arquillian.launch`: This system property is used to change the profile used by Arquillian. It should be `wildfly-embedded-mysql` to use the MySQL profile. @@ -345,7 +343,7 @@ using the MySQL database is: ``` -Darquillian.launch=wildfly-embedded-mysql --Dmysql.version=5.1.21 +-Dmysql.version=8.0.21 -Dwildfly.version=10.1.0.Final -Dwildfly.jbossHome=target/wildfly-10.1.0.Final -Dwildfly.modulePath=target/wildfly-10.1.0.Final/modules diff --git a/additional-material/wildfly/v10.1.0/standalone.xml b/additional-material/wildfly/v10.1.0/standalone.xml index 82b6cd3..e200694 100644 --- a/additional-material/wildfly/v10.1.0/standalone.xml +++ b/additional-material/wildfly/v10.1.0/standalone.xml @@ -150,9 +150,8 @@ - jdbc:mysql://localhost:3306/xcs - com.mysql.jdbc.Driver - mysql-connector-java-5.1.21.jar + jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe%2FMadrid + mysql-connector-java-8.0.21.jar xcs xcs diff --git a/additional-material/wildfly/v8.2.1/standalone.xml b/additional-material/wildfly/v8.2.1/standalone.xml index 27d702a..a974e69 100644 --- a/additional-material/wildfly/v8.2.1/standalone.xml +++ b/additional-material/wildfly/v8.2.1/standalone.xml @@ -153,9 +153,8 @@ - jdbc:mysql://localhost:3306/xcs - com.mysql.jdbc.Driver - mysql-connector-java-5.1.21.jar + jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe%2FMadrid + mysql-connector-java-8.0.21.jar xcs xcs diff --git a/pom.xml b/pom.xml index c71af9b..a117c83 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 2.0.0.0 0.7.9 4.12 - 5.1.21 + 8.0.21 3.0.24.Final 1.5.10 @@ -752,8 +752,8 @@ deploy ${project.build.directory}/mysql-connector-java-${mysql.connector.java.version}.jar data-source add --jndi-name=java:jboss/datasources/xcs --name=xcs-sample --jta=true --use-ccm=true - --connection-url=jdbc:mysql://localhost:3306/xcs --driver-name=mysql-connector-java-${mysql.connector.java.version}.jar - --driver-class=com.mysql.jdbc.Driver --user-name=xcs --password=xcs + --connection-url=jdbc:mysql://localhost:3306/xcs?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Europe%2FMadrid --driver-name=mysql-connector-java-${mysql.connector.java.version}.jar + --user-name=xcs --password=xcs /core-service=management/security-realm=RemotingRealm:add /core-service=management/security-realm=RemotingRealm/authentication=jaas:add(name="AppRealmLoopThrough") /subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name="security-realm", value="RemotingRealm") -- 2.18.1