Topic
  • No replies
SystemAdmin
SystemAdmin
1215 Posts

Pinned topic Datasource JNDI-Name

‏2006-08-03T15:04:40Z |
Hi,

I'm using WebSphere Application Server 6.0 and RAD.
I want to make a Database connection to Oracle 9i.

So I tried:
~~~~~~~~
public DBAccess(PrintWriter out) throws NamingException{
Hashtable env = new Hashtable();
env.putContext.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
InitialContext ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("java:comp/env/myDatasource");
}

public void openConnection()
{...
}
~~~~~~~
but got the following error:
A in the context "java:" found reference object named "comp/env/myDatasource" was sent to the JNDI Naming Manager gesendet. Following exception was logged. The reference data follows:
Classname of Reference-Factory: com.ibm.ws.util.ResRefJndiLookupObjectFactory
Positions-URLs der Referenz-Factory-Klasse: <null>
Reference Class Name: java.lang.Object
Type: ResRefJndiLookupInfo
Content: com.ibm.ws.util.ResRefJndiLookupInfo@674086fc ResRefJndiLookupInfo: Look up Name="myDatasource";JndiLookupInfo: jndiName="MYDB"; providerURL=""; initialContextFactory=""

~~~~~~~~
I also made an entry in the reference tab of Web-Deployment-Descriptor:

<resource-ref id="ResourceRef_1154610114018">
<description></description>
<res-ref-name>myDatasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

The database is called MYDB. I think the problem is that I don't know how the JNDI-name of the database is. How do I have to set the JNDI-Name of the database?

Hope, someone can help me.
Thank you in advance!