4 Replies Latest reply on Jul 2, 2012 9:46 AM by elvisd

    Configure mysql-ds.xml in Jboss 7.1

    bajrang_asthana

      Hi,

       

      I want to configure mysql-ds.xml file in Jboss 7.1. I have seen the section to configure datasource in standalone.xml file. But it looks different to my existing mysql-ds.xml file. Please see below the existing mysql-ds.xml file-

       

      <datasources>

        <local-tx-datasource>

          <jndi-name>MySqlDS</jndi-name>

          <connection-url>jdbc:mysql://localhost:3306/mm?autoReconnect=true</connection-url>

          <driver-class>com.mysql.jdbc.Driver</driver-class>

          <user-name>bajrang</user-name>

          <password>root</password>

          <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>

          <!-- should only be used on drivers after 3.22.1 with "ping" support

          <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>

          -->

          <!-- sql to call when connection is created

          <new-connection-sql>some arbitrary sql</new-connection-sql>

            -->

          <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers

          <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>

            -->

       

          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

          <metadata>

             <type-mapping>mySQL</type-mapping>

          </metadata>

        </local-tx-datasource>

      </datasources>

        • 1. Re: Configure mysql-ds.xml in Jboss 7.1
          elvisd

          Here my standalone.xml snippet

           

                  <subsystem xmlns="urn:jboss:domain:datasources:1.1">

                      <datasources>

                          <datasource jndi-name="java:/myDS" pool-name="my-pool" enabled="true" use-java-context="true" use-ccm="true">

                              <connection-url>jdbc:mysql://127.0.0.1:3306/thedb</connection-url>

                              <driver>mysql</driver>

                              <pool>

                                  <min-pool-size>10</min-pool-size>

                                  <max-pool-size>100</max-pool-size>

                                  <prefill>true</prefill>

                              </pool>

                              <security>

                                  <user-name>user</user-name>

                                  <password>Zecret</password>

                              </security>

                              <statement>

                                  <prepared-statement-cache-size>100</prepared-statement-cache-size>

                                  <share-prepared-statements>true</share-prepared-statements>

                              </statement>

                          </datasource>

               ...

                          <drivers>

                              <driver name="mysql" module="org.mysql"/>

                          </drivers>

           

          I had to define a module org/mysql in modules directory (to do this create a org/mysql/main folder structure in modules, copy mysql-jdbc.jar in it, and adapt a module.xml copied from another module)

           

          hth

          • 2. Re: Configure mysql-ds.xml in Jboss 7.1
            elvisd
            • 3. Re: Configure mysql-ds.xml in Jboss 7.1
              bajrang_asthana

              Thanks, I have defined datasource configuration in standalone.xml like below-

              <subsystem xmlns="urn:jboss:domain:datasources:1.0">

                          <datasources>

                              <datasource jndi-name="java:/MySqlDS" pool-name="ExampleDS" enabled="true" use-java-context="true">

                                  <connection-url>jdbc:mysql://localhost:3306/mm?autoReconnect=true</connection-url>

                                  <driver>mysql</driver>

                                  <security>

                                      <user-name>bajrang</user-name>

                                      <password>root</password>

                                  </security>

                              </datasource>

                              <drivers>

                                  <driver name="mysql" module=".">

                                     

                                  </driver>

                              </drivers>

                          </datasources>

                      </subsystem>

              But still getting below error-

              service status report

              JBAS014775:    New missing/unsatisfied dependencies:

                    service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/MySqlDS]

              I have copied the jdbc driver in the root directory of .ear file.

              • 4. Re: Configure mysql-ds.xml in Jboss 7.1
                elvisd

                The module is deployed before your ear, so i think that the jat must not be in the ear itself.

                Please check the linked video.