Advertisement

09.13.2005 at 10:53AM PDT, ID: 21560035
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Configuring a DB2 DataSource

Tags: db2, datasource
This is my first attempt at trying to (1) connect to a database using DataSources and (2) connecting to DB2. So please try to keep the responses as simple as possible.

When I start my application - a struts based Java webapp running on WAS 5.1 under WinXP - I get the following error during server initialization when connecting to the DataSource:

[9/12/05 9:14:39:641 EDT] 30ee7a04 Helpers       W NMSV0605W: A Reference object looked up from the context "java:" with the name "comp/env/jdbc/localds1" was sent to the JNDI Naming Manager and an exception resulted. Reference data follows:
Reference Factory Class Name: com.ibm.ws.util.ResRefJndiLookupObjectFactory
Reference Factory Class Location URLs: <null>
Reference Class Name: java.lang.Object
Type: ResRefJndiLookupInfo
Content: com.ibm.ws.util.ResRefJndiLookupInfo@3b307a14 ResRefJndiLookupInfo: Look up Name="jdbc/localds1";JndiLookupInfo: jndiName="jdbc/ds1"; providerURL=""; initialContextFactory=""

Exception data follows:
javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: jdbc/ds1: First component in name jdbc/ds1 not found.  Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
    at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.handleNameNotFound(WsnOptimizedNamingImpl.java:1983)
    at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.getNextWsnOptimizedNamingContext(WsnOptimizedNamingImpl.java:1320)
....

My code follows -

web.xml:

<resource-ref id="ResourceRef_1126121987734">
  <description></description>
  <res-ref-name>jdbc/localds1</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
  <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

Web Deployment Wizard (RAD 6.0):

  References:
     Resource Ref jdbc/localds1
     Name: jdbc/localds1

     Bindings:
        JNDI Name: jdbc/ds1

Java Source code:

...
params.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.ibm.websphere.naming.WsnInitialContextFactory");
params.put(Context.PROVIDER_URL, "iiop:///");
ctx = new InitialContext(params);
ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/localds1");     // Source of my error?
...

Application Deployment Descriptor Wizard (RAD 6.0):

  Deployment:
     DataSources:
        JDBC Provider:
           Name: DB2
           Class: com.ibm.jcc.DB2Connection PoolDataSource
        DataSource:
           Name: Data source 1
           JNDI Name: jdbc/ds1
        Resource Properties:
           databaseName: JSPA
           driverType: 4
           serverName: localhost
           portNumber: 50000

Database Explorer (RAD 6.0):

  JSPA (jdbc:db2:JSPA)
     Connection Name: DB2Conn
     Alias: JSPA
     Classes: .../db2jce_license_cu.jar;.../db2jce.jar;
     Connection URL: jdbc:db2:JSPA
     Driver: com.ibm.db2.jce.DB2Driver (IBM DB2 Universal)
     User/Pwd: User's O/S userId & PWD

From this wizard (Database Explorer), I can test the connection and it is successful.

Thanks for any help/suggestions.
Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: softechnics
Solution Provided By: Morientes
Participating Experts: 1
Solution Grade: A
Views: 167
Translate:
Loading Advertisement...
09.14.2005 at 08:23AM PDT, ID: 14881583

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 08:48AM PDT, ID: 14890392

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 08:54AM PDT, ID: 14890473

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 09:49AM PDT, ID: 14890994

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 11:24AM PDT, ID: 14891892

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 11:55AM PDT, ID: 14892205

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 12:18PM PDT, ID: 14892436

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 12:54PM PDT, ID: 14892831

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 01:16PM PDT, ID: 14893057

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 01:48PM PDT, ID: 14893328

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.15.2005 at 02:03PM PDT, ID: 14893442

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
09.14.2005 at 08:23AM PDT, ID: 14881583
// Source of my error?
Yes.

Change this:
ds = (javax.sql.DataSource) ctx.lookup("java:comp/env/jdbc/localds1");

to this:
ds = (javax.sql.DataSource) ctx.lookup("jdbc/localds1");
 
09.15.2005 at 08:48AM PDT, ID: 14890392
I had tried that with the same results.

Since then, I went into the Admin Console and added the DataSource there. I thought the EAR Deployment Descriptor was all that was needed. Still not sure that it wasn't, however, as a result of changing the code per your suggestion and the changes  made through the Admin Console, I now get a different error message as follows:

SEVERE: Error setting up the DataSource: javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: jdbc/localds1: First component in name localds1 not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

A step closer to, or further from, the solution?
 
09.15.2005 at 08:54AM PDT, ID: 14890473
I deleted the DataSource definition from the Server Admin Console, redeployed my EAR file and restarted the Server. Same error message as in previous post.
 
09.15.2005 at 09:49AM PDT, ID: 14890994
I noticed this:
 Deployment:
     DataSources:
        JDBC Provider:
           Name: DB2
           Class: com.ibm.jcc.DB2Connection PoolDataSource
        DataSource:
           Name: Data source 1
           JNDI Name: jdbc/ds1    <---- when you are requesting jdbc/localds1
        Resource Properties:
           databaseName: JSPA
           driverType: 4
           serverName: localhost
           portNumber: 50000

Make sure you have the same name (jdbc/localds1) in your code, web.xml, and declare this connection on the WebSphere Admin Console (wich you didn't mention above), open http://localhost:9090/admin and got to +Resources +JDBC Providers +DB2 Universal JDBC Driver Provider (i'm supposing that you've already configure the db2 driver on websphere) +Data Sources and +New

Let me know of your progress.
 
09.15.2005 at 11:24AM PDT, ID: 14891892
(1) My understanding is that " JNDI Name: jdbc/ds1"  refers to the global JNDI name and, in the web deployment descriptor (WDD), the global name is bound to the local name by the section:

-References
   Resource Ref jdbc/localds1
   Name: jdbc/localds1
   -Bindings
      JNDI Name: jdbc/ds1

And, finally, my code refers to the local JNDI name which is mapped to the global JNDI name in the WDD.

Is my understanding incorrect?

(2) Also, am I to understand that the DataSource has to be defined in both the App Deployment Descriptor in my EAR file and also in the server Admin Console? Seems like a duplication of effort, since the DatSource config info is in the EAR when it is deployed on the server.

Thanks for the clarifications.


 
09.15.2005 at 11:55AM PDT, ID: 14892205
One additional point, probably irrelevent. I'm deploying/running this app on the RAD server, not the target server. I noticed you gave me a URL to access the Admin Console, that's why I brought it up. Again, it's probably irrelevent, just wanted to clarify.
 
09.15.2005 at 12:18PM PDT, ID: 14892436
(2) Seems like a duplication of effort  [I agree]

(1) Check out my App configuration files so you can see things more clearly:
web.xml
      <resource-ref id="ResourceRef_1104201616312">
         <res-ref-name>DataSource</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>CONTAINER</res-auth>
         <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

ibm-web-bnd.xmi
  <resRefBindings xmi:id="ResourceRefBinding_1104201616312" jndiName="jdbc/myDataSource">
    <bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1104201616312"/>
  </resRefBindings>


I have never used the res-ref-name in none of my applications, what i do use is the JNDI name "jdbc/myDataSource"  to get the connection to my DataBase


Conclusion: set the JDNI name to jdbc/localds1
 -Bindings
      JNDI Name: jdbc/localds1
 
09.15.2005 at 12:54PM PDT, ID: 14892831
I've noticed in several instances during server startup, I've encountered this error message:

Caused by: com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException: DSRA0023E: The DataSource implementation class "com.ibm.db2.jcc.DB2ConnectionPoolDataSource" could not be found.

Can you tell me where this class should be located?

(Still working on your previous config change suggestions.)
 
09.15.2005 at 01:16PM PDT, ID: 14893057
Which version of DB2 are you using?

Read this if is 7.X:
One possible reason for this exception is that a user is attempting to use a JDBC 2.0 DataSource, but DB2 is not JDBC 2.0-enabled. This situation frequently happens with new installations of DB2 because DB2 provides separate drivers for JDBC 1.X and 2.0, with the same physical file name. By default, the JDBC 1.X driver is on the class path.

To confirm this problem:

On Windows systems, look for the inuse file in the java12 directory in your DB2 installation root. If the file missing, you are using the JDBC 1.x driver.
On UNIX systems, check the class path for your data source. If the class path does not point to the db2java.zip file in the java12 directory, you are using the JDBC 1.x driver.

To correct this problem:

On Windows systems, stop DB2. Run the usejdbc2.bat file from the java12 directory in your DB2 instalation root. Run this file from a command line to verify that it completes successfully.
On UNIX systems, change the class path for your data source to point to the db2java.zip file in the java12 directory of your DB2 installation root.



Tip:
Enter www.ibm.com and search for DSRA0023E (or whatever your error code is), this is how i got this^.
 
09.15.2005 at 01:48PM PDT, ID: 14893328
I'm running DB2 v8.1.7.445.
I'm running a WAS 5.1 server.
My JDK is at 4.2.06.

My DB2 installation directory is c:\Program Files\IBM\SQLLIB

In that folder, there is no java12 folder (nor is there a java12 folder in any subfolder). The only hits on 'java12' in doing a search from the 'c:\Program Files\ IBM' folder are several copies of 'npjava12.dll'.

 
09.15.2005 at 02:03PM PDT, ID: 14893442
Ok, then you have to configure the DB2Driver in WebSphere, in the admin console go to +Environment +Manage WebSphere Variables
and set these 2 variables (change the path to whatever your intallation directory is):

DB2UNIVERSAL_JDBC_DRIVER_PATH=C:\SQLLIB\java
DB2_JDBC_DRIVER_PATH=C:\SQLLIB\java\db2java.zip

I use the ASTK and SiteDeveloper(they must be very simillar to RAD 6.0 i think), go to the server perspective, double click on the server name, go to the variables tab and search for the above.
Accepted Solution
 
 
20080236-EE-VQP-29