0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WildFly 18 + mysql 8.0

Last updated at Posted at 2019-12-17

WildFly でのJDBCドライバの設定

管理画面での設定は、エラーが出るので断念

参考にさせていただきました。
https://qiita.com/masahiro-aoike/items/1fb9b4d0fdf38c1314c9

######ドライバファイルをコピー

  1. Wildfly_home/modules/system/layers/base/com/mysql/main/ ディレクトリを作成
  2. 配下に mysql-connector-java-8.0.18.jar をコピー
      Windows は、C:\Program Files (x86)\MySQL\Connector J 8.0 にインストールされているものをコピー
  3. 配下に module.xmlを作成
module.xml
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.5" name="com.mysql">
    <resources>
        <resource-root path="mysql-connector-java-8.0.18.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.servlet.api" optional="true"/>
    </dependencies>
</module>

######ドライバを登録
standalone.xmlのdatasourcesセクション内のdriversセクションにドライバを追加

standalone.xml
  <drivers>
    <driver name="mysql" module="com.mysql">
      <xa-datasource-class>com.mysql.cj.jdbc.MysqlXADataSource</xa-datasource-class>
    </driver>
  </drivers>

#####権限の追加が必要

GRANT XA_RECOVER_ADMIN ON *.* TO ‘usuario’@’localhost’;
FLUSH PRIVILEGES;

#####データソースを設定

standalone.xml
  <datasources>
    :
    :
    <xa-datasource jndi-name="java:/webdemo" pool-name="webdemo" enabled="true">
      <xa-datasource-property name="URL">
        jdbc:mysql://localhost:3306/webdemo?serverTimezone=JST
      </xa-datasource-property>
      <driver>mysql</driver>
      <transaction-isolation>TRANSACTION_REPEATABLE_READ</transaction-isolation>
      <xa-pool>
        <min-pool-size>2</min-pool-size>
        <initial-pool-size>2</initial-pool-size>
        <max-pool-size>4</max-pool-size>
        <prefill>true</prefill>
        <flush-strategy>FailingConnectionOnly</flush-strategy>
      </xa-pool>
      <security>
        <user-name>loginuser</user-name>
        <password>loginpassword</password>
      </security>
      <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
        <background-validation>true</background-validation>
        <background-validation-millis>60000</background-validation-millis>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
      </validation>
      <statement>
        <share-prepared-statements>false</share-prepared-statements>
      </statement>
    </xa-datasource>
    :
    :
  </datasources>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?