This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Servlets and the fly likes DataSource Pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "DataSource Pooling" Watch "DataSource Pooling" New topic

DataSource Pooling

Ramesh Pappala
Ranch Hand

Joined: Sep 14, 2005
Posts: 50
I had a problem in the following servlet program.

I added the resource tag to "server.xml",which contains all the details about database connection and about the number of connections it has to open.

<Resource name="jdbc/myoracle" auth="Container"
<ResourceParams name="jdbc/myoracle">
<value>jdbc racle:thin:@ORASRV:1521:MIRACLE</value>

And my "web.xml" file contains

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

<description>Oracle DataSource Example </description>
<res-ref-name>jdbc/myoracle </res-ref-name>




And my servlet class contains

import javax.servlet.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import javax.naming.InitialContext.*;

public class EmployeeDetails extends GenericServlet
public void init()
System.out.println("Servlet Intialised");
public void service(ServletRequest request,ServletResponse response) throws ServletException,IOException
PrintWriter out=null;

Context initContext=new InitialContext();
Context encContext=(Context)initContext.lookup("java:/comp/env");
DataSource ds=(DataSource)encContext.lookup("jdbc/myoracle");
//DataSource ds=(DataSource)initContext.lookup("java:/comp/env/jdbc/myoracle");
Connection con=ds.getConnection();
System.out.println("Connection Created");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from emp1");
//Statement st1=con.createStatement();
//ResultSet rs1=st1.executeQuery("Select * from r_employee");
// }

out.println("Resultset Processed </body></html>");
catch(Exception e)
public void destroy()
System.out.println("Servlet Destroyed");

and i wrote the html file also

iam getting an error as

java.sql.SQLException: Cannot load JDBC driver class 'null'

Is there is any problem with in server.xml or in the servlet class file

Please tell me where is the problem and how to solve it.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63551

Please do not post the same question more than once.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: DataSource Pooling
It's not a secret anymore!