Add New Datasource (mysql) wildfly

I am trying to add a new mysql jdbc datasource driver to my wildfly server

I created a wildfly.xxx/modules/system/layers/base/com/mysql/main folder. I have a jdbc jar file and module.xml

<module xmlns="urn:jboss:module:1.3" name="com.mysql">
        <resources>
         <resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
     </resources>
     <dependencies>
      <module name="javax.api"/>
     </dependencies>
    </module>

then the dataresource code is added to standalone-full.xml (under the datareources tag)

 <datasource jndi-name="java:jboss/datasources/MySQLDS" pool-name="MySQLDS"     enabled="true" use-java-context="true">
 <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
 <driver>MySQLDriver</driver>
<security>
 <user-name>root</user-name>
 <password></password>
</security>
</datasource>

but when I go to the wildfly http://localhost:9990/console/ dataresource control panel does not appear, what am I missing?

Also I am trying to add it manually from the interface i'v got this error

Unexpected HTTP response: 500

Request
{
    "address" => [
        ("subsystem" => "datasources"),
        ("data-source" => "mysql")
    ],
    "operation" => "test-connection-in-pool"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid",
    "rolled-back" => true
} 
+5
source share
5 answers

Have you added a driver definition? The subsystem datasourcesshould look something like this:

    <subsystem xmlns="urn:jboss:domain:datasources:2.0">
        <datasources>
            <datasource jndi-name="java:/jdbc/myds" pool-name="myds" enabled="true" use-java-context="true">
                <connection-url>jdbc:mysql://localhost/mydb</connection-url>
                <driver>mysql</driver>
                <security>
                    <user-name>foo</user-name>
                    <password>bar</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">
                    <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

driver driver . module MySQL.

+9

( ). , , :)

, , , , , ! , , . , , , ~

enter image description here

enter image description here

+3

, wildfly

  • standalone.xml
  • , xml.

// WildFly datasource xml

<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
      <datasource jndi-name="APP_DS" pool-name="APP_DS" enabled="true" use-ccm="false">
        <connection-url>jdbc:mysql://localhost:3306/DB_NAME</connection-url>
        <driver-class>com.mysql.jdbc.Driver</driver-class>
        <driver>mysql</driver>

        <!-- sql to call when connection is created -->
        <new-connection-sql>SELECT 1</new-connection-sql>

        <pool>
            <min-pool-size>5</min-pool-size>
            <max-pool-size>50</max-pool-size>
        </pool>

        <security>
          <user-name>username</user-name>
          <password>password</password>
        </security>

        <!-- sql to call on an existing pooled connection when it is obtained from pool -->
        <validation>
        <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
        </validation>

        <timeout>
        <blocking-timeout-millis>300000</blocking-timeout-millis>
        <idle-timeout-minutes>5</idle-timeout-minutes>
        </timeout>
        <statement>
        <track-statements>true</track-statements>
        </statement>      
      </datasource>
    </datasources>
+1

, . .

0

   <datasource jndi-name="java:/MySqlDS" pool-name="MySqlDS">
            <connection-url>jdbc:mysql://localhost/kunde</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <driver>mysql-connector-java-8.0.16.jar</driver>
            <security>
                <user-name>test</user-name>
                <password>1234</password>
            </security>
            <validation>
                <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
                <background-validation>true</background-validation>
                <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
            </validation>
        </datasource>
0

Source: https://habr.com/ru/post/1570761/


All Articles