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 Unable to connect to Data Source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Unable to connect to Data Source" Watch "Unable to connect to Data Source" New topic
Author

Unable to connect to Data Source

Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Hello,

I'm not able to connect to Data Source with different methods.
Really appreciate any suggestions.



With above code I'm getting error
Datasource Error :Cannot instantiate class: com.ibm.Websphere.naming.WsnInitialContextFactory



With this code it is going into exception with not details
Datasource Error :jdbc/ds1
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30501
    
150

Dilip,
Do you get any error messages when starting up the server? Are you using WSAD or WebSphere (app server) ?


[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
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Thanks for the response. Looks like I was getting the above errors because I forgot to save the server configuation when I added the data source. After saving the server I'm getting different error now. I'm running the application on WSAD 5 test application server.

[11/18/04 17:05:20:016 EST] 397eb5a7 ConnectionFac I J2CA0122I: Resource reference jdbc/ds1 could not be located, so default values of the following are used: [Resource-ref settings]

res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)

[11/18/04 17:05:21:375 EST] 397eb5a7 ConnectionFac I J2CA0107I: Component-managed authentication alias not specified for connection factory or datasource DS1.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30501
    
150

Dilip,
You need to specify the password somewhere. It is prefered to use J2C (java connector) to do this. See the J2C tab on the server. If you want to harcode the password in the datasource itself, this message is expected.
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Jeanne,

When I go to "Modify Data Source" screen I don't see any fields for database/host name, User ID and Password. I'm wondering how the data source works without these fields. Looks like I'm missing something here.

Thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30501
    
150

They are actually custom properties that you define in the bottom section of the screen. They are not there by default. Presumably because they want to encourage the use of J2C.
Milind Patil
Greenhorn

Joined: Oct 19, 2003
Posts: 26
Hi,

If you go in admin page you will find configuration of Data source. There you can configure data source.(username/password/url/min/max connections etc.)

Milind


Milind B. Patil - SCJP-1.4, SCWCD-5.0, SCBCD-5.0
Goutam Bhattacharjee
Ranch Hand

Joined: Aug 05, 2003
Posts: 44
I think this problem is occurring, becoz u r using a "Version 5.0 Datasource"
For this version u require to setup a JAAS security Profile. U can set up this profile from the "Security" tab of the server configuration. (Dbl-click the server to open the server configuration). In this tab, go to the table "JAAS Authentication Entries", click on "Add" button, and enter a userid and password.
After u have set up the JAAS profile, u need to go to the "Datasource" tab, select ur datasource, click "Edit" and go to the 2 drop down boxes at the bottom. (These are "Component-managed authentication alias" & "Container-managed authentication alias"). Enter the JAAS userid which u have just created in these 2 boxes.
Now save ur settings and restart the server and try again.
Let me know if that helps.


gb
Dilip kumar
Ranch Hand

Joined: Oct 16, 2000
Posts: 360
Thanks for the suggestions. I made the changes you suggested.

In the "Security" tab and under "JAAS Aunthentication Entries:" I now have
Alias:serve1
User ID:server1

In the "Data sources" tab and under "Data source defined in the JDBC provider selected above:"
I could see
Name : DS1
JNDI Name:jdbc/ds1
Type:V5
I have selected serve1 for component-managed and container-managed authentication alias.

In the "J2C" tab and under "J2C Connection Factories:" I could see
Name : DS1_CF
JNDI Name:eis/jdbc/ds1_CMP

But still I'm getting following message

[11/24/04 10:07:04:516 EST] 645ab97b ConnectionFac I J2CA0122I:
Resource reference jdbc/ds1 could not be located,
so default values of the following are used: [Resource-ref settings]

res-auth: 1 (APPLICATION)
res-isolation-level: 0 (TRANSACTION_NONE)
res-sharing-scope: true (SHAREABLE)
res-resolution-control: 999 (undefined)
[ November 24, 2004: Message edited by: Dilip kumar ]
Murtuza Akhtari
Ranch Hand

Joined: Aug 07, 2004
Posts: 108
Regards to Dilip's second post ---

That by the way is not an error....Its just a message which tells you that you are using the jndi name instead of a resource reference (which WebSphere suggests is the way to go )

Have you created a resource reference in the web.xml ??

If not create a resource reference and use "java:comp/env/ResRefName" in your lookup

In your web.xml go to the References tab, thn go to Resource tab(on the top)
Your ResRefName will be "serve1" since thats the alias tht u have already created. make sure your res ref is called serve1 (case sensitive --as a precaution --since jndi is case sensitive). also enter the jndi name of your datasource which will be jdbc/ds1. Select javax.sql.DataSource as the type. Let the authentication and Sharing remain Container and Shareable respectively.

Also since its a V5 DataSource, you will need to create the Alias in JAAS. This alias should be the same as the resource reference that you create. Select the resource reference in the Container and component managed authentication in the DataSource properties(which you have already done)
and you will not see that message.
[ November 24, 2004: Message edited by: Murtuza Akhtari ]

---<br />SCJP 1.4
Krish Dasari
Greenhorn

Joined: Jul 05, 2005
Posts: 1
When creating a connection factory or data source, a JNDI name is given by which the connection factory or data source can be looked up by a component. Generally an "indirect" name with the java:comp/env prefix should be used. This makes any resource-reference data associated with the application available to the connection management runtime, to better manage resources based on the res-auth, res-isolation-level, res-sharing-scope, and res-resolution-control settings.


Also, Refer the website:
http://publib.boulder.ibm.com/infocenter/wasinfo/v5r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rdat_jnditips.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to connect to Data Source