Freki
Freki

Reputation: 167

Wildfly 10 can't connect datasource: invalid connection

Problem

I'm trying test my connection and it keeps giving me the same error while at first sight I can't see what I did wrong. Maybe I'm overlooking something...

Error

    nexpected HTTP response: 500

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

    Response

    Internal Server Error
    {
        "outcome" => "failed",
        "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0047: Connection is not valid",
        "rolled-back" => true
    }


Standalone-full.xml

    <subsystem xmlns="urn:jboss:domain:datasources:4.0">
                <datasources>
                    <datasource jta="true" jndi-name="java:/ProjectenDS" pool-name="ProjectenDS" enabled="true" use-ccm="true">
                        <connection-url>jdbc:mysql://localhost:3306/projecten3db</connection-url>
                <driver-class>com.mysql.jdbc.Driver</driver-class>
                <driver>mysql-connector-java-5.1.40-bin.jar_com.mysql.jdbc.Driver_5_1</driver>
                <pool>
                    <min-pool-size>10</min-pool-size>
                    <initial-pool-size>11</initial-pool-size>
                    <max-pool-size>100</max-pool-size>
                </pool>
                <security>
                    <user-name>projecten</user-name>
                    <password>projecten</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>
        </datasources>
    </subsystem>

Upvotes: 11

Views: 49485

Answers (5)

durga murugan
durga murugan

Reputation: 11

try to check is there any error like "Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false,"

wrong :jdbc:mysql://localhost:3306/demodb right :jdbc:mysql://localhost:3306/demodb?useSSL=false

...this worked for me!.

and also make sure!

1.mysql connector added 2.turn off "windows firewall" plus any "antivirus" firewall 3.driver class,pool size,connection url with port number

refer: https://mkyong.com/mysql/mysql-establishing-ssl-connection-without-servers-identity-verification-is-not-recommended/

Upvotes: 0

Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

If your datasource is not XA, open standalone.xml and remove the datasource-class property from your datasource definition. Wildfly adds it even if you don't specify it whe you create the datasource.

You may have to restart the server to see it working.

Upvotes: 2

Dima Fomin
Dima Fomin

Reputation: 1330

We had such error on MS SQL when our user was not mapped to requested database

Upvotes: 0

rodrigomelo
rodrigomelo

Reputation: 69

I solved this error by reducing pool size and set prefill attribute to false on datasource settings.

<pool>
   <min-pool-size>5</min-pool-size>
   <max-pool-size>10</max-pool-size>
   <prefill>false</prefill>
   <use-strict-min>false</use-strict-min>
   <flush-strategy>IdleConnections</flush-strategy>
</pool>

Upvotes: 1

user2543120
user2543120

Reputation: 131

The exception you have is generic.

Check on {WILDFLY_HOME}/standalone/log/server.log

You can use tail -f server.log while you test on the web console.

This will give you the right error to work on.

Upvotes: 8

Related Questions