3 Replies Latest reply on Jan 9, 2007 1:17 PM by Ron Jawanda

    mysql connection refused

    Ron Jawanda Novice

      I have jboss 4.0.2 running on my ubuntu linux server.

      I have 5.0.1 mysql and the 3.0.1 mysql-connector

      My datasource gets registered ad MySqlDSL
      and in the jmx console it says bind name


      So far so good.

      I my war application (i connect using ) this

      Statement stmt =null ;
      ResultSet rs = null;
      boolean test = false ;

      try {
      InitialContext ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("java:/MySqlDSL");
      con = ds.getConnection();
      con.setTransactionIsolation(con.TRANSACTION_SERIALIZABLE) ;

      stmt = con.createStatement();
      StringBuffer sb = new StringBuffer() ;

      sb.setLength(0) ;

      Jboss throws and exception

      JbossManagedConnectionPool throwable while attempting to get a new connection: null

      communications lik failure du to underlying exception
      java.net.ConnectException Connection refused

      my connection-url string is

      my username and password are correct.

      I try this on the command line and I can login.

      Any idea?

      Thanks a million if you answer.

        • 1. Re: mysql connection refused
          Ron Jawanda Novice

          Here is my datasource binding with no exceptions.

          13:24:40,333 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDSL to JNDI name 'java:MySqlDSL'
          13:24:41,641 INFO

          Here is the actual exception

          13:17:18,695 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:


          MESSAGE: java.net.ConnectException: Connection refused


          java.net.SocketException: java.net.ConnectException: Connection refused
          at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
          at com.mysql.jdbc.MysqlIO.(MysqlIO.java:284)
          at com.mysql.jdbc.Connection.createNewIO(Connection.java:2569)
          at com.mysql.jdbc.Connection.(Connection.java:1485)
          at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
          at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:151)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:508)
          at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:207)
          at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:534)

          • 2. Re: mysql connection refused
            Peter Johnson Master

            The "connection refused" error message typically means that the server is not listening on the port, or that the firewall has the port blocked. Did you change the default port for MySQL (it usually uses port 3306)? Have you tried turning off iptables (I assume that is the firewall you are using)?

            • 3. Re: mysql connection refused
              Ron Jawanda Novice

              It was a little confusing but I got it working.
              I had changed the port tp 3305 and thought I fixed the xml configuration file. It now works. Thanks for your post.