1 Reply Latest reply on May 25, 2007 7:16 PM by Micho Edershvili

    problem connecting mysql

    Micho Edershvili Newbie

      Hi with jboss 4.2 I have problems connecting with mysql when deploying my application (it worked well on another server, but I cant find the difference).

      From the commandline on the same server I can connect to mysql without problems

      mysql -u bbcJbossUser -p -h localhost bbcJboss

      my mysql-ds.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>MySqlDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/bbcJboss</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>bbcJbossUser</user-name>
       <password>GEHEIM</password>
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>



      I get the following output on the console:
      ...
      10:53:37,435 INFO [EntityBinder] Bind entity com.babuco.session.Session on table Session
      10:53:37,524 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
      10:53:37,528 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
      10:53:37,531 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
      
      ** BEGIN NESTED EXCEPTION **
      
      java.net.ConnectException
      MESSAGE: Connection refused
      
      STACKTRACE:
      
      java.net.ConnectException: Connection refused
       at java.net.PlainSocketImpl.socketConnect(Native Method)
       at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
       at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
       at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
       at java.net.Socket.connect(Socket.java:519)
       at java.net.Socket.connect(Socket.java:469)
       at java.net.Socket.<init>(Socket.java:366)
       at java.net.Socket.<init>(Socket.java:208)
      ...
      




        • 1. Re: problem connecting mysql
          Micho Edershvili Newbie

          I found the solution.

          The database is bound to the servers IP adress, because I have to talk to it from an other server.

          Therefore in mysql-ds.xml
          it is wrong to write localhost, though it is the same server.

          <connection-url>jdbc:mysql://localhost:3306/JbossDB</connection-url>

          we have to spcecify its IP adress
          <connection-url>jdbc:mysql://xx.xx.xx.xx:3306/JbossDB</connection-url>