Does anybody know whether I can use multiple data sources in a single stateless session bean in EJB3?
I want to develop a session bean to aggregate a lot data and return, but these data comes from 2 data sources, is this possible?
Can someone provide a sample on this?
Thanks very much !
Yes, as long as the DataSources are both capable of being enlisted in the same transaction (i.e., are XA capable). Simply create two separate resources, and bind them to separate DataSource objects.
Unfortunately, data source creation and EJB bindings are vendor-specific, so it’s not really possible to provide an example unless you mention which application server you’re using.