• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DI of Datasource in stateless session bean

 
hashmukh punamia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am trying a simple example to Inject Datasource in the session bean using DI.
I am able to connect to the database and get the connection.
But when I execute the query, I get the following error.

java.sql.SQLException: Table not found in statement [select student_name from student_mark]

I am using JBoss 4.2.2.GA and NetBeans6.1 RC2.

Code for DI in Session Bean is


My execute query is:


I am using global jndi and the code in the ds file in the deploy directory of JBoss server is:


Dont know whether the problem is with the database or in my code

Thanks,
Hashmukh
 
Jim Janssens
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your mapped named is 'DefaultDS', that is the resource that the container is going to bind to the resource ref you made using annotations. So the container is going to create a local resource ref with name 'test' and he is going to bind 'DefaultDS' to that local ref.

Anywhere, starting from your bean, you can now do a manual lookup of 'test' but it will always map to 'DefaultDS'. JBOSS automatically deploys an HSQL db under that JNDI name (DefuaultDS). So you are indeed getting a successful connection, but to the in memory database started by JBOSS instead of your oracle database.

You should probably supply the correct mapped name to which the oracle connection is made available under (probably 'test' if I look at your configuration at the bottom)
 
hashmukh punamia
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim ........Its working now :-)

Thanks,
Hash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic