• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

DI of Datasource in stateless session bean

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jim ........Its working now :-)

Thanks,
Hash
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic