This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Websphere and the fly likes Creating  Datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Creating  Datasource" Watch "Creating  Datasource" New topic
Author

Creating Datasource

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30392
    
150

"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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Creating Datasource