Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating Datasource

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have create DataSource and JNDI name WSAD5.1

Datasource name is MyDataSource and jndi name is jdbc/LoginDS.
following code is working properly.
below is my database connection code:
public Connection getConnection() throws SQLException,NamingException{
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup ("jdbc/LoginDS");
Connection con = ds.getConnection("scott","tiger");
return con;
}
If

I lookup using java:comp/env/jdbc/LoginDS
that's not working .
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Raj",

We're pleased to have you here with us in the IBM/Websphere forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks,
Jeanne
Forum Bartender
 
Martin Lira
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to create a resource reference (java:comp/env/jdbc/LoginDS)in you web deployment descriptor that refers to the jndi name jdbc/LoginDS

Martin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic