[KEYCLOAK-11331] - MySQL support

This commit is contained in:
Pedro Igor 2020-10-21 09:37:16 -03:00 committed by Marek Posolda
parent ee82391bd2
commit a965025be8
4 changed files with 24 additions and 2 deletions

View file

@ -54,6 +54,10 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mariadb-deployment</artifactId> <artifactId>quarkus-jdbc-mariadb-deployment</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql-deployment</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-web-deployment</artifactId> <artifactId>quarkus-vertx-web-deployment</artifactId>

View file

@ -36,6 +36,7 @@
<jackson.version>2.11.2</jackson.version> <jackson.version>2.11.2</jackson.version>
<jackson.databind.version>${jackson.version}</jackson.databind.version> <jackson.databind.version>${jackson.version}</jackson.databind.version>
<hibernate.version>5.4.21.Final</hibernate.version> <hibernate.version>5.4.21.Final</hibernate.version>
<mysql-connector-java.version>8.0.21</mysql-connector-java.version>
<picocli.version>4.5.1</picocli.version> <picocli.version>4.5.1</picocli.version>
<snakeyaml.version>1.20</snakeyaml.version> <snakeyaml.version>1.20</snakeyaml.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version> <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
@ -91,6 +92,11 @@
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version> <version>${snakeyaml.version}</version>
</dependency> </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View file

@ -55,6 +55,10 @@
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mariadb</artifactId> <artifactId>quarkus-jdbc-mariadb</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql</artifactId>
</dependency>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
<artifactId>quarkus-core</artifactId> <artifactId>quarkus-core</artifactId>

View file

@ -124,6 +124,8 @@ public final class PropertyMappers {
return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect"; return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect";
case "mariadb": case "mariadb":
return "org.hibernate.dialect.MariaDBDialect"; return "org.hibernate.dialect.MariaDBDialect";
case "mysql":
return "org.hibernate.dialect.MySQL8Dialect";
case "postgres-95": case "postgres-95":
return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL95Dialect"; return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusPostgreSQL95Dialect";
case "postgres": // shorthand for the recommended postgres version case "postgres": // shorthand for the recommended postgres version
@ -139,6 +141,8 @@ public final class PropertyMappers {
return "org.h2.jdbcx.JdbcDataSource"; return "org.h2.jdbcx.JdbcDataSource";
case "mariadb": case "mariadb":
return "org.mariadb.jdbc.MySQLDataSource"; return "org.mariadb.jdbc.MySQLDataSource";
case "mysql":
return "com.mysql.cj.jdbc.MysqlXADataSource";
case "postgres-95": case "postgres-95":
case "postgres-10": case "postgres-10":
return "org.postgresql.xa.PGXADataSource"; return "org.postgresql.xa.PGXADataSource";
@ -152,12 +156,14 @@ public final class PropertyMappers {
return "h2"; return "h2";
case "mariadb": case "mariadb":
return "mariadb"; return "mariadb";
case "mysql":
return "mysql";
case "postgres-95": case "postgres-95":
case "postgres-10": case "postgres-10":
return "postgresql"; return "postgresql";
} }
throw invalidDatabaseVendor(db, "h2-file", "h2-mem", "mariadb", "postgres", "postgres-95", "postgres-10"); throw invalidDatabaseVendor(db, "h2-file", "h2-mem", "mariadb", "mysql", "postgres", "postgres-95", "postgres-10");
}, "The database vendor. Possible values are: h2-mem, h2-file, mariadb, postgres95, postgres10."); }, "The database vendor. Possible values are: h2-mem, h2-file, mariadb, mysql, postgres95, postgres10.");
create("db", "quarkus.datasource.jdbc.transactions", (db, context) -> "xa", null); create("db", "quarkus.datasource.jdbc.transactions", (db, context) -> "xa", null);
create("db.url", "db", "quarkus.datasource.jdbc.url", (db, context) -> { create("db.url", "db", "quarkus.datasource.jdbc.url", (db, context) -> {
switch (db.toLowerCase()) { switch (db.toLowerCase()) {
@ -170,6 +176,8 @@ public final class PropertyMappers {
case "postgres-95": case "postgres-95":
case "postgres-10": case "postgres-10":
return "jdbc:postgresql://${kc.db.url.host:localhost}/${kc.db.url.database:keycloak}${kc.db.url.properties:}"; return "jdbc:postgresql://${kc.db.url.host:localhost}/${kc.db.url.database:keycloak}${kc.db.url.properties:}";
case "mysql":
return "jdbc:mysql://${kc.db.url.host:localhost}/${kc.db.url.database:keycloak}${kc.db.url.properties:}";
} }
return null; return null;
}, "The database JDBC URL. If not provided a default URL is set based on the selected database vendor. For instance, if using 'postgres-10', the JDBC URL would be 'jdbc:postgresql://localhost/keycloak'. The host, database and properties can be overridden by setting the following system properties, respectively: -Dkc.db.url.host, -Dkc.db.url.database, -Dkc.db.url.properties."); }, "The database JDBC URL. If not provided a default URL is set based on the selected database vendor. For instance, if using 'postgres-10', the JDBC URL would be 'jdbc:postgresql://localhost/keycloak'. The host, database and properties can be overridden by setting the following system properties, respectively: -Dkc.db.url.host, -Dkc.db.url.database, -Dkc.db.url.properties.");