Is there any way to provide user credentials to intialContext while lookup of the datasource in JBoss EAP 6
Issue
- How to Secure Data Source in JBoss EAP?, how to achieve Data Source lockup with security (Means if we provided username and password then only need access of datasource)?. Below example is without providing username/password we are able to lockup data source, we have to do below configurations:
1)Web.xml
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
2) jboss-web.xml
<jboss-web>
<resource-ref>
<res-ref-name>jdbc/datasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<jndi-name>java:/TestDS</jndi-name>
</resource-ref>
</jboss-web>
JavaClient: (javax.sql.DataSource) ctx.lookup(“java:/TestDS”);
- We created Microsoft SQL datasource using JBoss admin console.Our requirement is if we provide username and password and DataSource name then only lookup needs to be done,how to achive this in JBoss EAP 6? Our requirement is we need to provide username and paasword to intialContext valid username and password of database users only need to access.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
