[jboss-user] [Beginners Corner] - Jboss DataSource Lookup question

bilin2006 do-not-reply at jboss.com
Thu Feb 15 11:31:36 EST 2007

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?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4017113#4017113

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4017113

More information about the jboss-user mailing list