File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes Connect to websphere data source from external application Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Websphere
Reply locked New topic
Author

Connect to websphere data source from external application

kireet pola
Greenhorn

Joined: Aug 22, 2010
Posts: 12
Hello,

I wrote the following code for connecting to the websphere datasource from external application:

Properties prop = new Properties();

prop.put(Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
prop.put(Context.PROVIDER_URL,"iiop://localhost:2811");

InitialContext init = new InitialContext(prop);

DataSource ds = (DataSource) init.lookup("jdbc/testDS");

//Connection conn = ds.getConnection("USER NAME","PASSWORD");
Connection conn = ds.getConnection();

If, I give the username/pwd while retrieving the connection it is working but it is not working if i don't give them.

For resolving the above problem, I tried setting up the authentication alias(custom properties for the data source) and tried to access it through them. But no luck.

Is it possible to connect through the custom proerties ? I set up them with the names: "user and password" and used them while getting the connection. Do I need to create the properties with different names ?

Any suggestions will be a lot helpful.

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 13842

That's just a duplicate of this post as far as I can see. Please don't post duplicate questions.
 
IntelliJ Java IDE
 
subject: Connect to websphere data source from external application
 
Threads others viewed
sqlserver datasource configuration
Websphere Connection Pooling
Connection pool with multiple users
Datasource Configuration
Accessing DataSource outside container
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture