[jboss-user] [JBoss Tools Users] - Re: How to create a JDBC connection

Oliver Roell do-not-reply at jboss.com
Thu Sep 3 06:55:52 EDT 2009


Now I have tried the old school approach:


  | Context context = new InitialContext();
  | DataSource ds = (DataSource) context.lookup("java:OracleDS");
  | 

It works. After fighting some hours with JBoss it really works.

But something must be wrong with my first dependency injection attempt.

The following annotations are all invalid and create null-values:


  | @Resource(name="jdbc/OracleDS", mappedName="java:OracleDS")
  | private DataSource ds1;
  | 
  | @Resource(name="java:OracleDS")
  | private DataSource ds2;
  | 
  | @Resource(name="java/OracleDS")
  | private DataSource ds3;
  | 
  | @Resource(name="jdbc:OracleDS")
  | private DataSource ds4;
  | 
  | @Resource(name="jdbc/OracleDS")
  | private DataSource ds5;
  | 

Does anybody know what's wrong with the Resource-annotations?
Do they work only within EJBs and not in servlets?


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

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



More information about the jboss-user mailing list