Hi,
I finally managed to get the JNDI-DataSource to work with Tomcat 4.0.3.
Here the setting of server.xml:
<Resource name="jdbc/BuergerPortalDb" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/BuergerPortalDb">
<parameter><name>factory</name><value>oracle.jdbc.pool.OracleDataSourceFactory</value></parameter>
<parameter><name>user</name><value>xxx</value></parameter>
<parameter><name>password</name><value>xxx</value></parameter>
<parameter><name>driverType</name><value>thin</value></parameter>
<parameter><name>serverName</name><value>server</value></parameter>
<parameter><name>portNumber</name><value>port</value></parameter>
<parameter><name>databaseName</name><value>dbName</value></parameter>
</ResourceParams>
Now, I added the following in my web.xml:
<resource-ref>
<description>description</description>
<res-ref-name>jdbc/BuergerPortalDb</res-ref-name>
<res-type>oracle.jdbc.pool.OracleConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
And finally, in the Java-File I added:
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ConnectionPoolDataSource cpds = (ConnectionPoolDataSource)
envCtx.lookup("jdbc/BuergerPortalDb");
PooledConnection pconn = cpds.getPooledConnection("xxx", "xxx");
Connection conn = pconn.getConnection();
And, you won't believe it, it really works!!!
But there's one odd point I want to correct:
The User/Password-Setting in the server.xml file is always ignored - I have always to
pass these two parameters when calling
getPooledConnection("name", "password");
If I call getPooledConnection() without these two parameters, I get some nice
exceptions.
Now it is quite tedious to store the user/password-combination in the source-code, if
you could store it in the server.xml...
Has anybody an idea how to make it work via server.xml only?
Frank
mailto:[EMAIL PROTECTED]
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>