3 Replies Latest reply on Sep 29, 2002 11:21 PM by mchuevo

    Unable to connect to mysql database inspite of ...

    shaikaman

      Hi all,

      I'm unable to solve a simple which you all might
      have done earlier.

      I've jboss-3.0.2 (binary installation)
      mysql database(3.23) and mm.mysql driver.

      I'm testing a simple test program with a servlet,jsp.
      Servlet has the database connection using ds.

      -------------------------------------------------------
      initialContext = new InitialContext();
      DataSource dataSource = (DataSource)
      initialContext.lookup("java:comp/env/MySqlDS");
      return dataSource.getConnection();
      ----------------------------------------------------------

      -------web.xml --------------

      <resource-ref>
      <res-ref-name>MySqlDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>
      -----------------------------

      I'm not able to connect to the database as a NamingNotFound
      Exception is thrown:

      These are the steps i've taken to connect to database,
      not working.

      > I put the mm.mysql.jar into server/default/deploy directory


      > copied jboss.jcml to server/default/conf directory

      ------ jboss.jcml ---


      org.gjt.mm.mysql.Driver



      org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImpl
      MySqlDS
      jdbc:mysql://server.techmines.com/VULCAN23
      root


      ---------------------

      > Edited standardjaws.xml

      -------- standardjaws.xml -----------
      java:/MySqlDS
      <type-mapping>mySQL</type-mapping>
      --------------------------------------

      > Edited mysql-service.xml

      --------- mysql-service.xml ------------

      <!--uncomment out this line if you are using the MySqlDbRealm above -->
      MySqlDbRealm

      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      MySqlDS



      <config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://server.techmines.com/VULCAN23</config-property>
      <config-property name="DriverClass" type="java.lang.String">org.gjt.mm.mysql.Driver</config-property>
      <!--set these only if you want only default logins, not through JAAS -->
      <config-property name="UserName" type="java.lang.String">root</config-property>
      <config-property name="Password" type="java.lang.String"></config-property>




      -----------------------------------------

      > Edited login-config.xml

      ----------- login-config.xml --------------

      <application-policy name = "MySqlDbRealm">

      <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
      <module-option name = "principal"></module-option>
      <module-option name = "userName">root</module-option>
      <module-option name = "password"></module-option>
      <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
      </login-module>

      </application-policy>
      ------------------------------------------

      Still, I get NamingException caught at : javax.naming.NamingException:
      Could not dereference object

      I'm really struck with this problem for the past few days.

      Please specify the steps where i went wrong or do i need to
      add few more configuration changes.
      I'm sweating with this problem, and Feedback Excepted sooon.


        • 1. Re: Unable to connect to mysql database inspite of ...
          jacke

          not need add resource in web.xml,you can use 'initialContext.lookup("java:/MySqlDS")' directly,and I put the my driver jar to lib folder.

          • 2. Re: Unable to connect to mysql database inspite of ...
            shaikaman

            Hi,
            Thanks! That method is working fine.
            But, my actual entry in Servlet is "java:comp/env/jdbc/VulcanDBJNDI".

            So I tried in the same way, and modified mysql-service,xml
            env/jdbc/VulcanDBJNDI

            I get an error as :jdbc not bound

            When i tried the same thing without "env" itz working quite nicely.

            What should i do now? How to solve this?

            TIA,
            Aman

            • 3. Re: Unable to connect to mysql database inspite of ...
              mchuevo

              OK, I think the jboss.jcml, it's for past versions of jboss, i don't think you need that. Configure and deploy (server/default/deploy) the mysq-service.xml. The mysql driver must be in /server/default/lib . And you have to edit the standardjbosscmp-jdbc.xml and put the same lines that you put in standardjaws.xml. The lookup for the name it has to be java:/MySqlDS. I think that should do it.