I'm using Wildfly 10. At first I tried to create datasource via CLI.
A command deploy mysql-connector-java-6.0.4.jar
was executed well.
/subsystem=datasources:installed-drivers-list
shows that driver was installed
{
"driver-name" => "mysql-connector-java-6.0.4.jar",
"deployment-name" => "mysql-connector-java-6.0.4.jar",
"driver-module-name" => undefined,
"module-slot" => undefined,
"driver-datasource-class-name" => undefined,
"driver-xa-datasource-class-name" => undefined,
"driver-class-name" => "com.mysql.cj.jdbc.Driver",
"driver-major-version" => 6,
"driver-minor-version" => 0,
"jdbc-compliant" => false
}
But data source was not created with command
data-source add --name=zktest-datasource
--jndi-name=java:/jdbc/zktest-database --driver-name=mysql-connector-java-6.0.4.jar --connection-url=jdbc:mysql://localhost:3306/zktest --user-name=root --password=111
Connection test
/subsystem=datasources/data-source=zktest-datasource:test-connection-in-pool
was failed.
Now I trying to create datasource using standalone.xml
My modules.xml
<module xmlns="urn:jboss:module:1.1" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-6.0.4.jar">
</resource-root>
</resources>
<dependencies>
<module name="javax.api"></module>
<module name="javax.transaction.api"></module>
</dependencies>
</module>
modules.xml
placed into the JBOSS_HOME/modules/system/layers/base/com/mysql/jdbc
'Datasources' section in JBOSS_HOME/standalone/configuration/standalone.xml
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/MySqlDS" pool-name="MySqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/zktest</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>111</password>
</security>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql.jdbc">
<xa-datasource-class>com.mysql.cj.jdbc.Driver</xa-datasource-class>
</driver>
</drivers>
</datasources>
Now while deploing I see such message
WFLYCTL0184: New missing/unsatisfied dependencies: service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.driver-demander.java:jboss/datasources/MySqlDS, service org.wildfly.data-source.MySqlDS]
And while test connection in Wildfly control panel:
{ "outcome" => "failed", "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:jboss/datasources/MySqlDS", "rolled-back" => true }