Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Creating Datasource

 
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 .
 
author & internet detective
Posts: 40200
816
Eclipse IDE VI Editor Java
  • 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
 
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
 
I think I'll just lie down here for a second. And ponder this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic