-
1. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dkato Oct 7, 2002 11:57 AM (in response to ravn)Hello ravn,
I've been working with a Oracle Datasource called "OracleDB" using the template provided with JBoss 3.0 and it's working fine. Although I'm not using the security part yet it goes on very well.
To access the datasource "OracleDB" I use the followig command:
DataSource ds =(DataSource) ctx.lookup("jdbc/OracleDB");
return ds.getConnection();
but as you can see it calls direcly from the "java:" root context. I'm working on to create a standard like:
DataSource ds = (DataSource) ctx.lookup("jdbc/OracleDB");
return ds.getConnection();
One thing more, you cannot use "comp/env/jdbc/DataSource" because "comp/env/" is the root environment. Try "jdbc/DataSource".
Here goes the "oracle-service.xml" I'm using, hope it helps.
[]s
Diogo Catossi -
2. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
pkondaka Oct 23, 2002 10:28 AM (in response to ravn)Hey
Thanks for your input.
I am also using Oracle DS for my connection.
I configured oracle-service.xml
when i put following lines, i am getting error compiling 'DataSource'
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/CMISDS");
can you tell what jar do i need to keep in path
Thanks
KPK -
3. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dkato Oct 23, 2002 2:30 PM (in response to ravn)well,
you need to put on your code:
import javax.sql.DataSource;
and be shure that before you call the DataSource you declare the Initial context, like this:
Context ctx = new InitialContext();
DataSource ds =(DataSource) ctx.lookup("java:/OracleDS");
return ds.getConnection()
to your example:
Context ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:jdbc/CMISDS");
return ds.getConnection()
*note that I'm suposing you declared "jdbc/CMISDS" as the DataSource's JNDI name. -
4. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dahan Nov 14, 2002 10:28 AM (in response to ravn)I'd like to define a resource reference name in ejb-jar.xml and then define the real jndi name in jboss.xml
Here is what I did,
in ejb-jar.xml
<resource-ref>
<res-ref-name>jdbc/MySQL</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<resource-ref>
in jboss.xml
<resource-ref>
<res-ref-name>jdbc/MySQL</res-ref-name>
<jndi-name>jdbc/DefaultDS</jndi-name>
</resource-ref>
Then in my java code I would like to do
DataSource ds = (DataSource) ctx.lookup("java:jdbc/MySQL");
to find the data source. I could make this code work in iPlanet App Server, but not in Jboss. Any idea?
Thanks. -
5. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dnoyeb Nov 28, 2002 10:09 AM (in response to ravn)I got that error when I was first learning.
DataSource is not a class, you are supposed to replace that with a real class.
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/CMISDS");
is just an example the real code should be
MyClass ds = (MyClass) ic.lookup("java:comp/env/jdbc/CMISDS"); -
6. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dnoyeb Nov 30, 2002 10:53 AM (in response to ravn)Also you might look at my find here. it likely applies to you since I discovered it trying to use my own name for the datasource which was not DefaultDS. but if you already know how to use alternamte names in 3.x maybe its not interesting to you.
http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=forums/ -
7. Re: Renaming /OracleDS to /comp/env/jdbc/DataSource in JNDI
dnoyeb Dec 4, 2002 11:11 PM (in response to ravn)uhh, DataSource is a class :D its just in javax.sql and not in java.sql.....