I am new beginner of Jboss. Hope somebody can give me a clear concept of the following questions. Thanks in advance.
I setted up the DataSource in mysql-ds.xml file as follows:
and when I start up the jboss, jboss printed out the following information:
Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=MySqlDS' to JNDI name 'java:MySqlDS'
and in the program, I was supposed to code as follows:
Context ctx = new InitialContext();
ds = (DataSource)ctx.lookup("java:MySqlDS");
1). I want to know why I can't replace this sentence "ds = (DataSource)ctx.lookup("java:MySqlDS");" as "ds = (DataSource)ctx.lookup("java:comp/env/MySqlDS");"?
2). what is the difference between "java:MySqlDS" and "java:comp/env/MySqlDS"? Someone told me that "java:comp/env/MySqlDS" is mostly used in real project, but "java:MySqlDS" not.
3). I know "java:MySqlDS" is for getting a DataSource config in the *-ds.xml file, however "java:/comp/env/MySqlDS" is for using JDBC connections, is my opinion correct?
The comp/env space is supposed to be used within your EJBs. There is probably some good reason for that, but I don't recall exactly why. Probably to let the container know what JNDI resources you're using.