There are several ways to do that. You have to make a indirection.
1. You can put an entry into the context from jboss.
2. You can use a helper class, which gives you the name over a getDsName() method.
3. You can put your own entry into the JNDI, to reference your actual DB name.
I'm probably going to go for option 3 however I have tried this before and can't get it to work. Could you check this out and maybe point out what I'm doing wrong?
In ejb-jar.xml (for Member bean)
The Postgres database
Under the JNDI view for JBoss:
java:comp namespace of the MemberEJB bean:
+- env (class: org.jnp.interfaces.NamingContext)
| +- jdbc (class: org.jnp.interfaces.NamingContext)
| | +- MyDS[link -> java:/PostgresDS] (class: javax.naming.LinkRef)
In my code (for Member)
Context ctx = new InitialContext();
ds = (javax.sql.DataSource) ctx.lookup("jdbc/MyDS");
I have tried multiple variations and can't get it to work. I am using 3.0.0 RC1 btw.