File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes How to: DataSource in tomcat 5 with netBeans 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to: DataSource in tomcat 5 with netBeans 5" Watch "How to: DataSource in tomcat 5 with netBeans 5" New topic

How to: DataSource in tomcat 5 with netBeans 5

A Saari

Joined: Mar 31, 2006
Posts: 26
Hi All - this is an fyi post.

To use a JNDI/JDBC DataSource with Tomcat 5.5 and netBeans 5 do the following:

From the netBeans 'Runtime' tab go to the tomcat web server and start up the admin console. Create your data source there. For Oracle mine looks like:

jdbc racle:thin:@//localhost:1521/JIEDDO


Make sure you download the from Oracle and CHANGE THE NAME TO
ojdbc14.jar --- tomcat will NOT pick a .zip file.

Place ojdbc14.jar in the TOMCAT dir common/lib

You should now have an entry in your server.xml file that looks like:

url="jdbc racle:thin:@//localhost:1521/JIEDDO"

Leave it that way.

Now. Go back to the Projects tab in netBeans and edit your web.xml file - add this tag

IMPORTANT - DO NOT double click a .xml file from netBeans and edit it....the changes won't take. Instead you MUST select the file, right-click and select 'Edit'. This is a known 'feature' of netBeans 5.

<description>Oracle Datasource</description>

Next. Edit your context.xml file - it should look like this:

<Context path="/JIEDDO">
<ResourceLink name="jdbc/orclJIEDDO"

Last - almost there. Add this code to your java class:

Context ctx = new InitialContext();
DataSource dataSource = (DataSource)
Connection conn = dataSource.getConnection();

There. Done.

Good luck.

I agree. Here's the link:
subject: How to: DataSource in tomcat 5 with netBeans 5
Similar Threads
Crystal Reports: Error finding JNDI name
Crystal Reports XI and Sun One 6.1 web server SP 5 Error finding JNDI name
DataSource is Null in JNDI Connection with Tomcat
jsp page not show oracle data
Tomcat DataSource