The portable way to do this has always been to declare it in a resource-ref:
<resource-ref> <res-ref-name>jdbc/myDataSource</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Application</res-auth> </resource-ref>
Your code would then be looking up
to access the connection.
Thanks for the suggestion. But <resource-ref> tag is not supported in standalone.xml.
This tag could have been used in any Web applications, which has we.xml file. But my applciation is a server and it doesnt have any such files.
JBoss doc for Resource adapters says, it has such kind of support for having <application/> tag like
But I could not use this in my datasource configuration.
Following is my datasource configuration in standalone.xml. I would like to know how can I relate
with this configuration. How can I do that??
<datasource jndi-name="java:jboss/mydatabase" pool-name="mypoolname" enabled="true" jta="true" use-java-context="true" spy="true" use-ccm="true">
Thanks alot in advance.
Vin Prabhu wrote:
But my applciation is a server and it doesnt have any such files.
What kind of server?
How is it packaged?
I have deployed ear in standalone/deployment/appname.ear and sar within this standalone/deployment/appname.ear/appname.sar with which all application specific jars and config files.
My server doesnt have EJB, Webservices etc.
My server is written in Core Java to handle login, get database Connections, execute transactions etc.
I can't help with changes to the datasource configuration.
However, you might want to consider CDI enabling your jar(s) and then injecting your datasource with
@Resource(authenticationType = APPLICATION, lookup=..) private DataSource myDataSource;
CDI makes things really easy and you should check it out if you haven't already.
@Resource(authenticationType = APPLICATION)
This is supported. This is new feature in Java6.
But I want to know more about @Resource annotation. Can you please explain about authenticationType?
How exactly authenticationType = APPLICATION affects on DataSource? How to verify this?
What is difference between AuthenticationType.APPLICATION and AuthenticationType.CONTAINER?
Any other configurations needed for @Resource to work for DataSource??
Is the same tag <application-managed-security> supported in AS7.1 ??