Help us understand the problem. What is going on with this article?

mysql-connector-java-8.0.11 の XADataSourceクラスの所在

More than 1 year has passed since last update.

【MySQL8.0リリース記念】

MySQL server 8.0.11のリリースと同時に、Connector/J のバージョンもアップ。
新しいバージョンのConnector/J を使ってWildflyからアクセスしようと試みたらxa-datasourceクラスの名前が変更されていたのでメモ。

xa-datasourceクラスパスの確認
# jar tf mysql-connector-java-8.0.11.jar |grep XA
com/mysql/cj/jdbc/MysqlXAConnection.class
com/mysql/cj/jdbc/MysqlXADataSource.class
com/mysql/cj/jdbc/MysqlXAException.class
com/mysql/cj/jdbc/SuspendableXAConnection.class
com/mysql/cj/protocol/x/XAsyncSocketConnection.class
com/mysql/cj/protocol/x/XAuthenticationProvider$1.class
com/mysql/cj/protocol/x/XAuthenticationProvider.class

"com/mysql/cj/jdbc/MysqlXADataSource.class"が該当

ドライバファイルをコピー
  1. Wildfly_home/modules/system/layers/base/com/mysql/main/ ディレクトリを作成
  2. 配下に mysql-connector-java-8.0.11.jar をコピー
  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.11.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セクションにドライバを追加
上記で調べたクラスパスをxa-datasoure-classとして記載する

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

うまく登録されていれば、Wildflyの起動時のログに下記のように表示される。

server.log
... INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) WFLYJCA0018: Started Driver service with driver-name = mysql
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした