3 Replies Latest reply on Jan 7, 2005 2:42 AM by priyananda

    Help requested for MySql data source connection problem

    priyananda

      Dear Friends,
      After spending lot of time in finding a solution on the net, including JBOSS forums FAQ, finally I resorted to this posting having no alternate.
      Please help me if any one is aware of this problem.

      I hava a session bean running on "a.b.c.d" machine where JBOSS4.0 is running.

      I have a MySql Database running on "x.y.z.m" machine.

      From a remote client machine, I am accessing the above session bean and invoking a method on it. The invoked method is successful when I deploy my "FmDbSource" programatically, that means its JNDI name appears in "Global JNDI Name Space".

      Inorder to eliminate the manual deployment of my Datasource, I created the following "mysql-ds.xml" and put it in "deploy" directory of JBOSS server. Now the JNDI name appears in "java:" name space. That is fine.


      <local-tx-datasource>
      <jndi-name>FmDbSource</jndi-name>
      <connection-url>jdbc:mysql://x.y.z.m:3306/Fms_db</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>Fms_Client</user-name>
      Fms_Client

      </local-tx-datasource>



      As my session bean is running on the same JBOSS machine, I am expecting it to get the "java:FmDbSource". But I am getting the following error.


      08:29:55,040 INFO [STDOUT] org.jboss.resource.adapter.jdbc.WrapperDataSource@6a150e
      08:29:55,665 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
      org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Syntax error or access violation message from server: "Access denied for user: 'Fms_Client'@'a.b.c.d' to database 'Fms_db'")
      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)

      I have double checked about database user id, passwd & JBOSS server m/c access previleges on my mysql server m/c.

      Here is my session bean code which access the datasource.

      env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "jnp://a.b.c.d:1099"); env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
      initial = new InitialContext(env);
      ds = (DataSource) initial.lookup("java:FmDbSource");

      I also tried like this.
      2) //initial = new InitialContext(env);
      initial = new InitialContext();
      ds = (DataSource) initial.lookup("java:FmDbSource");

      My doubt is that, is it required to have the MySql server to run on the same JBOSS machine?
      Or are there any other settings/configurations need to be done inorder to make this setup work properly.

      Any help is greatly appreciated.
      I thank you very much for your extended help in advance.

        • 1. Re: Help requested for MySql data source connection problem

          Moderated FAQ:

          AND IT IS THE FIRST *?**?** STICKY POST IN THIS FORUM

          • 2. Re: Help requested for MySql data source connection problem

            If you are incapable of understanding the FAQ how do you expect to
            understand any response in these forums?

            • 3. Re: Help requested for MySql data source connection problem
              priyananda

              Hi Adrian,

              First of all I am sorry If I am doing anything wrong. I am very new to this forum and first time I am using JBOSS.

              I could understand FAQ to the best of my knowledge.

              Finally I figured out that there is an '_' in MySql user name(on server side) which created all this problem. To be honest, Still I could not understand how it worked earlier with same user name.

              At the same time, I request you not to discourage new comers like me by questioning about the capability of understanding FAQ, etc... Because In a distributed environment if some thing is not working, suspecting & verifying each s/w component involved is the first step in the diagonasis process.

              Anyway I request you to delete my posting as the problem / solution is not w.r.t JBOSS.

              Once again, I am really sorry if you concider it as a distrabance to you and other forum friends.

              Thanks