6 Replies Latest reply on May 2, 2013 8:32 AM by arun2arunraj

    Whether our Plugin can support JNDI

    arun2arunraj

      Hi Developers,

       

         For Our Use-Case, We guess JNDI is best than jdbc for mysql database connection.

       

         Based on my observation, RHQ supporting JDBC (rhq-server-4.5.1\jbossas\server\default\deploy\jms) . I we dont find any datasource for mysql (rhq-server-4.5.1\jbossas\server\default\deploy).

       

         If we are specifying mysql-ds.xml in the path(rhq-server-4.5.1\jbossas\server\default\deploy). Can we get JNDI database connection ? or we have to do something else ? or we cant get JNDI connection from RHQ. We guess RHQ is deployed in JBoss, So we can get JNDI database connecion in RHQ.(Is it right?)

       

       

      Regards,

      ArunRaj

        • 1. Re: Whether our Plugin can support JNDI
          lkrejci

          It depends on what you want to do

           

          If you want to access a JNDI resource from an agent plugin, putting the datasource into RHQ server will not help you, because it won't be available in the agent. Therefore, in your agent plugin you would need to carry all the libraries necessary to connect to your JNDI server of choice and manage the connection to it on your own in your agent plugin code.

           

          If you want to modify RHQ server itself or write a server plugin, you will be able to access your datasource. You can look here https://docs.jboss.org/author/display/RHQ/Server+Plugin+Development to see what RHQ server plugins are about.

          1 of 1 people found this helpful
          • 2. Re: Whether our Plugin can support JNDI
            arun2arunraj

            Hi Lukas,

             

                I want to connect JNDI from my Agent. For that, could you tell the files which I am missing ( mysql-connector-java.jar , jndi-properties.jar,jndi-1.2.1.jar,mysql-ds.xml , mysql-jdbc2-service.xml ). I think I am missing binding files. Can you help you to find a good path.

             

            Regards,

            ArunRaj.

            • 3. Re: Whether our Plugin can support JNDI
              tsegismont

              Arun,

               

              You can't do that. If you want your plugin to execute queries to a MySQL database, then make sure you plugins ships MySQL connector and create JDBC connections in your plugin code (or use an existing JDBC connection pool).

               

              Thomas

              • 4. Re: Whether our Plugin can support JNDI
                arun2arunraj

                Hi Thoms,

                 

                    Can you share your knowledge, Why we cant do it ?.

                 

                     I am curious to know the reasons and what to upgrade myself to the industries standard. As per this article, JNDI is the best than JDBC Connection pooling. And RHQAgent is running in jvm (If we are supplied any API, So it can run that). And of course, JDBC Connection poolings are possible. Then why we cant access JNDI in rhq agent. Please guide as always you guys do.

                 

                Regards,

                ArunRaj

                • 5. Re: Whether our Plugin can support JNDI
                  tsegismont

                  You can connect to a remote JNDI server from any JVM. But you can't retrieve a Datasource object.

                   

                  Yes Datasources in JNDI are the preferred way to get JDBC connections in an application server. But if you want to query a database from your plugin code, which will run in the agent JVM, then create JDBC connections manually or use a JDBC connection pool like commons-dbcp or C3P0.

                  • 6. Re: Whether our Plugin can support JNDI
                    arun2arunraj

                    Hi Thomas,

                     

                        I understand your point. Thank you so much for guiding me.

                     

                    Regards,

                    ArunRaj.