dcsimg
Exception Creating DataSource with Tomcat & JNDI
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   EJ_Chambers
Posted On:   Friday, July 12, 2002 06:47 AM

I am trying to setup a JNDI Reference on our Tomcat 4.0.4 Server. My server.xml entry looks like this: driverClassName oracle.jdbc.driver.OracleDriver driverName jdbc:oracle:thin:@SERVERNAME:1521:DBNAME user NAME password PWD My web.xml looks like this: resource-ref> jdbc/maxz javax.sql.DataSource Container If I run my JSP Page, I get the exception: javax.naming.NamingException: Exception creating DataSource: org.hsql.jdbcDriver This is not the dr   More>>

I am trying to setup a JNDI Reference on our Tomcat 4.0.4 Server. My server.xml entry looks like this:


			






driverClassName
oracle.jdbc.driver.OracleDriver


driverName
jdbc:oracle:thin:@SERVERNAME:1521:DBNAME


user
NAME


password
PWD








My web.xml looks like this:


			
resource-ref>

jdbc/maxz


javax.sql.DataSource


Container







If I run my JSP Page, I get the exception: javax.naming.NamingException: Exception creating DataSource: org.hsql.jdbcDriver


This is not the driver I have specified above. This is the default/example driver that comes in fresh install of Tomcat, which I have taken out. I am positive if I get the correct Driver Reference, it will work, but there lies my problem. Any ideas??


Here is my JSP page which I am using to debug with...


			
<%@ page import="javax.naming.*, java.sql.*, javax.sql.*" %>

<%
Context ctx;
DataSource ds;

try{
InitialContext jndiCntx = new InitialContext();
java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

try{
ctx=(Context) jndiCntx.lookup("java:comp/env/");

out.println("Env Values:
");
NamingEnumeration ne = jndiCntx.list("java:comp/env/jdbc");
out.println(ne.toString() + "
");
while(ne.hasMoreElements()){
Object ob = ne.next();
out.println(ob + "
");
}

out.println("JDBC Values
");
NamingEnumeration enum = ctx.list("jdbc/");
while (enum.hasMore()){
Object a = enum.next();
out.println(" --> "+ a);
}

out.println("
Looking up jdbc/maxz
");

try{
ds = (DataSource) ctx.lookup("jdbc/maxz");
out.println("Found It!!!");
/*
try{
Connection conn = ds.getConnection("maximo", "maximo");
out.println("Got Connection");
Statement st = conn.createStatement();
out.println("Got Statement");
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM EMPLOYEES");

out.println("Employee Count: " + rs.getString(1));
st.close();
conn.close();
}catch(Exception e){
out.println("DB Error: ");
out.println(e.getMessage());
}
*/
}catch(Exception e){
out.println("Error: On DataSource Lookup
");
e.printStackTrace(new java.io.PrintWriter(out));
}

}catch(Exception e){
out.println("Error: On Context Lookup
");
}finally{

}


}catch(Exception e){
out.println("Error: On Initial Context
");
}

Thanks in advance!!

Ej Chambers
   <<Less

Re: Exception Creating DataSource with Tomcat & JNDI

Posted By:   David_Graff  
Posted On:   Tuesday, July 16, 2002 11:42 AM

I am taking a wild stab in the dark on this one and it might be wrong but then again...

I was just looking into something regarding this with JBoss that is just driving me batty.

The default configuration in server.xml for tomcat sets up a datasource for the context /examples. Under that they define a HyperSonic datasource. Try commenting out the /example Context and see if that works.

Re: Exception Creating DataSource with Tomcat & JNDI

Posted By:   EJ_Chambers  
Posted On:   Friday, July 12, 2002 07:40 AM

Nevemind! I just noticed that my server.xml was wrong! Sorry about the post
About | Sitemap | Contact