Do you just have two datasources to select from or can it be a long list. If there are just two, you can register both of them with the application server and then include both of them in the
EJB deployment descriptors. Then you can use either one of them in your program depending on the selection.
If the list of possible datasources is long then thats probably a much more compilcated issue and I can't think of a way to do it cleanly.