3 Replies Latest reply on Oct 26, 2006 8:18 AM by sonoerin

    unable to connect to db

    sonoerin

      I am unable to get my app to connect to a running instance of mySQL. I can connect to it via Eclipse IDE using a URL:

      jdbc:mysql://localhost:3306/mydb

      But in my mysql-ds.xml file I have this:


      <local-tx-datasource>
      <jndi-name>MySqlDS</jndi-name>
      <connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>user</user-name>
      <pass word>none</pass word> <-- formatted to show in this post
      </local-tx-datasource>


      But when I try to access the site I get this:

      Caused by: org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Cannot connect to MySQL server on 127.0.0.1:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.lang.NumberFormatException))
      at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:161)
      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)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:395)
      at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:297)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:447)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:874)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:103)


      Does anyone know what might prevent JBOss 4.0.2 from connecting to the db?

        • 1. Re: unable to connect to db
          sonoerin

          I should say that I am on OS 10.4.8 running JDK1.5 with JBoss-4.0.2 and the mysql db is running locally.

          • 2. Re: unable to connect to db
            jaikiran

             

            (java.lang.NumberFormatException))
            at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:161)


            Not sure why you would see a NumberFormatException. Just give it a try by changing the connection url to:

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



            • 3. Re: unable to connect to db
              sonoerin

              That did it, I have no idea why it will accept a name, and not an IP and then throw a NumberException. But it appears to be working now - thanks!