-
1. Re: datasource referencing
shogun Apr 26, 2002 8:08 AM (in response to mcauleyt)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. -
2. Re: datasource referencing
mcauleyt Apr 26, 2002 11:16 AM (in response to mcauleyt)Thanks,
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 jboss.xml:
<resource-managers>
<resource-manager>
<res-name>jdbc/MyDS</res-name>
<res-jndi-name>java:/PostgresDS</res-jndi-name>
</resource-manager>
</resource-managers>
In ejb-jar.xml (for Member bean)
<resource-ref>
The Postgres database
<res-ref-name>jdbc/MyDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
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.
Many thanks,
Tim