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

    Help requested for MySql data source connection problem

    Priyananda Sivakumar Newbie

      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.