Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Servlet : Session invalidate
Oracle Connection Pooling in 3 2 2
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Running a Simple JMS Example
Tomcat and webapplication specific java library path
Mapping in workers2 properties
org apache jasper JasperException
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action
   MESSAGE
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
Value attribute of <html:checkbox
url string for connecting jboss to oracle
javax servlet ServletException: BeanUtils populate
5 0 18: Windows XP Pro vs Windows 2000
HTTP Status 404 The requested resource is not available
 
Please help...

Please help...

2007-09-02       - By Brian Munroe

 Back
On 8/31/07, Mike Cronin <mike.cronin@(protected)> wrote:

> I am having a problem setting up a connection-pool via JNDI on Tomcat 6.0.14
> utilizing Oracle 10g. Currently I have a <Resource> for my DataSource
> referenced within a <Context> element within the server.xml file. The
> classes12.jar file which contains the Oracle Driver, exists within the
> $CATLINA-HOME/lib. I am able to successfully access my tables outside of the
> connection pool so I know that I am getting to the driver.

Mike:

First thing I can tell you, quoting directly from the Tomcat Docs:

"For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place
<Context> elements directly in the server.xml file. This is because it
makes modifing the Context configuration more invasive since the main
conf/server.xml file cannot be reloaded without restarting Tomcat."

Now that I've said that, I'll admit I struggled with connection
pooling about a month ago.  My problem was that I was trying to place
the driver jar file in either shared/lib or WEB-INF/lib.  This was
incorrect and it needed to be in $CATALINA_HOME/common/lib, where
Tomcat could manage it.  If you read the classloader section on
tomcat.apache.org it will make sense why this is.

You mention that it is located it $CATALINA_HOME/lib [sic] - which
I'll assume is a typo, but it leads to ambiguity - did you mean
common/lib or shared/lib?  Definitely move it to common/lib.

After trying to get my JDBC resources to work in
<GlobalNamingResource> without much luck.  I ended up placing my
<Resource> definitions in META-INF/context.xml.  I don't know if you
are trying to define a global pool for all your applications or can
live with a local app configuration, I made due with a local
configuration.

Regardless, here is my "hello, world" recipe:

In META-INF/context.xml file:

<Resource name="jdbc/XEDB"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:ghg/ghg@//192.168.1.14:1521/XE"
maxActive="100"
maxIdle="30"
maxWait="10000"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"
/>

I didn't mess around with setting username and password attributes, I
just provided them within the connection URL.

Finally, in a JSP, I have the following code:

(mind you this is just a 'hello, world' - I'd never actually recommend
this in real life)

<jsp:directive.page import="javax.naming.*" />
<jsp:directive.page import="java.sql.*" />
<jsp:directive.page import="javax.sql.*" />

<%

InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/XEDB");
Connection conn = ds.getConnection();

Statement s = conn.createStatement();

ResultSet rs = s.executeQuery("select * from hello");

while(rs.next()) {
   out.println(rs.getString(1) + "<br/>");
}

s.close();
conn.close();

%>

I deleted, for example, <resource-ref>'s, and basically returned
conf/server.xml and WEB-INF/web.xml back to stock, which I had mucked
up from trying things googling had suggested I try.

Hopefully this works for you too!

BTW, classes12.jar is designed for JDK 1.2 and 1.3.  From what you
mentioned, it is working just fine with your non-pooling code, but you
can download [1] a newer version (odbc14.jar comes with Oracle XE).

-- brian

[1] - http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc
_10201.html

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.