• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNDI look up for data source

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi folks,
i am just novice to WSAD which i am working in right now. i have Oracle 9i and i want to make database connection frow WSAD. i have a following code snippet found online:
Connection connection = null;
InitialContext ictx = new InitialContext();
dataSource = (DataSource) ictx.lookup("java:comp/env/jdbc/JCampDS");
connection = dataSource.getConnection();
.........
now proble is, how do I get ("java:comp/env/jdbc/JCampDS") which is a pointer to a database( if i am not wrong).
i would appreciate if anyone could explain me all steps for it. thanks.
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically, you define the configuration of the datasource (i.e. the database URL, JDBC driver, username and password for the underlying connection pool) with a vendor specific tool. Not sure what this is for WS, although with WebLogic you use the web-based administration console.
Once you've setup your datasource, you then use something like the code snippet you found to look up and use it.
I'll move this over to the Websphere forum so they they can help you out further...
Cheers
Simon
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The snippet you've found takes advantage of local resource references. I would first go and read a good book on EJB's so that you understand the issues involved with local and global JNDI references -- Richard Monson-Haefel's pops to mind immediately.
Then what you will need to do is to first define the local reference in the EJB deployment descriptor editor, then define the mapping from the local reference to a global reference in the EJB extensions editor. Finally (or first -- take your pick) you will have to define a corresponding Database Driver and Datasource having a matching global JNDI name in the server configuration editor.
Kyle
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How do I create a resource reference to my MySQL Datasource in WebSphere Application Server v5.1 ?

I have configured it in WAS and assigned a JNDI name of 'jdbc/MySQLDataSource' to it using the administration console. However, I cannot find a place where I can map a resource reference to my JNDI name.

Say, for example, if I create the resource reference as explained above in my web.xml, will I need to create additional entries in other files (analogous to server.xml in Tomcat? or is that already taken care of when I created the data source in WAS?)

Regards,
Shahnawaz
reply
    Bookmark Topic Watch Topic
  • New Topic