wood burning stoves 2.0*
The moose likes Tomcat and the fly likes how to configure oracle DataSource into Tomcat 6 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "how to configure oracle DataSource into Tomcat 6" Watch "how to configure oracle DataSource into Tomcat 6" New topic
Author

how to configure oracle DataSource into Tomcat 6

shriram iyer
Ranch Hand

Joined: Dec 10, 2003
Posts: 43
how to configure oracle DataSource into Tomcat 6.

i want some sample server.xml and web.xml files
Donald Winston
Greenhorn

Joined: Jul 16, 2010
Posts: 16
I use postgres. Oracle will be the same except for the connection url.

You need this in web.xml: (child of root element)
<!-- Database configuration for each DataSource is in xpertda/META-INF/context.xml -->
<resource-ref>
<description>The PostgreSQL DataSource for the xpertda web app.</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

You need this in context.xml in the directory <web-app>/META-INF: (Context element is the root element)

<?xml version="1.0" encoding="UTF-8"?>
<Context reloadable="true" crossContext="true">

<!-- maxActive: Maximum number of dB connections in pool. Make sure you
configure your connections large enough to handle all of your db connections.
Set to -1 for no limit. -->

<!-- maxIdle: Maximum number of idle dB connections to retain in pool. Set
to -1 for no limit. See also the DBCP documentation on this and the
minEvictableIdleTimeMillis configuration parameter. -->

<!-- maxWait: Maximum time to wait for a dB connection to become available
in ms, in this example 5 seconds. An Exception is thrown if this timeout
is exceeded. Set to -1 to wait indefinitely. -->

<!-- username and password: dB username and password for dB connections. -->

<!-- driverClassName: Class name for the JDBC driver. -->

<!-- url: The JDBC connection url for connecting to your dB. -->

<Resource name="jdbc/postgres"
auth="Container"
type="javax.sql.DataSource"
maxActive="-1" maxIdle="-1" maxWait="5000" validationQuery="select 1"
username="webuser" password="webuser"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/test" />

</Context>
Donald Winston
Greenhorn

Joined: Jul 16, 2010
Posts: 16
I forgot to mention you have to copy oracle jdbc driver to Tomcat's library not you web app's library.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to configure oracle DataSource into Tomcat 6
 
Similar Threads
JUDDI Data sorce validation error
Datasource Configuration
Getting database connection using datasource
Configure Datasource with Tomcat
JBoss + Oracle -- Urgent