1 of 1 people found this helpful
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.
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.
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).
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.
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.
I understand your point. Thank you so much for guiding me.