I'm trying to lookup a jndi datasource in Tomcat 4.0b7 but I must be missing
something.
I'm able to view the bindings but I get an error trying to instantiate the
datasource. How do I specify the factory and what value should I use to
instantiate the Oracle DataSource class?
I am able to view the bindings successfully with:
Context initCtx = new InitialContext();
Context theComponentContext = (Context) initCtx.lookup ("java:comp/env");
NamingEnumeration enum2 = theComponentContext.listBindings("jdbc");
while (enum2.hasMore()) {
Binding binding = (Binding) enum2.next();
out.println("Name: " + binding.getName());
out.println("Type: " + binding.getClassName());
out.println("Value: " + binding.getObject());
out.println();
}
In my server.xml, I have:
<Resource name="jdbc/oradb7" auth="SERVLET"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/oradb7">
<parameter><name>user</name><value>test</value></parameter>
<parameter><name>password</name><value>test</value></parameter>
<parameter><name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>driverName</name>
<value>jdbc:oracle:thin@localhost:1521:ORADB7</value></parameter>
</ResourceParams>
In the web.xml file of my context I have a valid reference to the resource:
<resource-ref>
<res-ref-name>jdbc/oradb7</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>SERVLET</res-auth>
</resource-ref>