tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trond Hersløv <trond.hers...@gotogate.no>
Subject RE: Tomcat 5 Database Connections
Date Fri, 18 Jun 2004 23:27:19 GMT
Hi!
I had the same problem. I was confused by all the different ways there are
to configure tomcat.
After five days I simply tried the simplest and most straight forward way.
Forget <GlobalNamingResources>, web.xml, <resource-ref>, <res-ref-name>.
Do it like this (based on the turorials MyFirst, and I know you know what to
subsitute so it sutes your app:
Put the following either inside your <Host></Host> in the server.xml or in
the work-dir (in my case: tomcat_home/conf/Catalina/localhost/MyFirst.xml).
It worked both ways.
Try this first as is. Do not put anything database related into your
WEB-INF/web.xml
This is my test, so I don't mind exposing login and password.
Maybe this isn't the correct way to do it, but it got me started and I can
change it later as I get more experienced.

Please give me comments if this would leed me into any kind of problems
later.


<Context docBase="MyFirst" path="/MyFirst"
workDir="work/Catalina/localhost/MyFirst">
<Resource name="jdbc/mysql" type="javax.sql.DataSource" auth="Container"/>
<ResourceParams name="jdbc/mysql">
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
  <name>maxActive</name>
  <value>200</value>
</parameter>
<parameter>
  <name>password</name>
  <value>.tomcat.</value>
</parameter>
<parameter>
  <name>url</name>
  <value>jdbc:mysql://localhost/demo</value>
</parameter>
<parameter>
  <name>driverClassName</name>
  <value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
  <name>maxIdle</name>
  <value>200</value>
</parameter>
<parameter>
  <name>username</name>
  <value>tomcat</value>
</parameter>
</ResourceParams>
</Context>


-----Opprinnelig melding-----
Fra: Shapira, Yoav [mailto:Yoav.Shapira@mpi.com]
Sendt: Friday, June 18, 2004 19:32
Til: Tomcat Users List; sextonj@odscompanies.com
Emne: [GFI-SPAM-BA] - RE: Tomcat 5 Database Connections - Bayesian
Filter detected spam



Hi,
A few notes:

First, I see on your other thread that you now have this working and
suspect something else was the cause, like a tag error.  I'm glad it's
working, and as you noted in the same message it's "rock solid."

Second, I just did a clean tomcat install and followed the JDBC
DataSource how-to *to the letter* to set up a connection pool for an
existing Oracle database.  I didn't run into any problems, including the
"cannot locate driver 'null' for url 'null' type of problem.  It works
exactly as expected.  This is obviously not my first time doing this,
but it's the first time I've done it manually from scratch in more than
a year, and I'm pleased to discover the document is complete and
accurate.

Third, and this is a bit superfluous but I'll mention it anyway: you
can't conclude that most users are finding it difficult from the
archives of this list.  The reason is that you don't hear from people
who succeed, because they have nothing to brag about, they just followed
the documentation.  All you hear from are those who are having problems,
which even if we heard about this once a day would still be a small
minority of tomcat users judging from the tomcat download counts.  Of
course this is an analysis that's hard to do precisely because we don't
know what percentage of downloaders use the connection pooling, but the
bottom line is still that you only hear problems and not good
experienced.

Finally, as to your point that this should be simpler: most of these
elements, specifically the Resource/ResourceParams declaration in a
server configuration file and matching resource link in web.xml, as well
as the JNDI environment namespace, are mandated by the J2EE
Specification.  It's not our choice to declare and configure things this
way.  The specific parameters, such as
maxActive/maxIdle/maxWait/username are mandated by the connection pool
implementation: even though we bundle DBCP and offer documentation for
it, we by no means require the user to use it.  It's trivial to swap
another DataSource pool provider and use that with tomcat instead.  So
most of this is out of our hands, and if you have a good idea for a
simpler mechanism the place to bring it up is the J2EE expert groups.

Yoav Shapira


Yoav Shapira
Millennium Research Informatics


>-----Original Message-----
>From: Jeff Sexton [mailto:sextonj@odscompanies.com]
>Sent: Wednesday, June 16, 2004 2:21 PM
>To: tomcat-user@jakarta.apache.org
>Subject: Tomcat 5 Database Connections
>
>This is part question and part observation regarding database
>connectivity under Tomcat (5.0.24).
>
>My application normally runs in production at my company on a
>Tomcat 4.0.4 server.  The applications includes Cocoon and access
>to several databases (Sybase) via both Tomcat connections from
>servlets and from Cocoon XSP pages.  I've been at this for awhile
>now and I'm a huge fan of Tomcat (and Cocoon).
>
>On a new test server I setup Tomcat 5.0.24 and installed my
>applications.  For sometime I thought all was well because
>most of my stuff is Cocoon driven, and it's fine, including
>database connectivity.
>
>This week I realized that my servlets are getting:
>
>org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver
of
>class ''
>for connect URL 'null', cause: null
>
>I've spent several days now trying to fix this.  I've read verious
posts
>from this list's archive, and several other places.  I've studied
>many examples, and done google after google on it.
>
>My conclusion is that for whatever reason *a lot* of people have
>this trouble with TC 5x.  However there are very few solutions.
>
>Yes, my jdbc jar file is in common/lib (and WEB-INF/lib, both).
>Yes, I've tried declarations in <GlobalNamingResources> and in the apps
><context>, either.  Yes web.xml contains a <resource-ref> with the
>same <res-ref-name>.  The only thing I have not done is to create
>a META-INF/context.xml (is defining these resources in server.xml
>simply broken?).
>
>I'm dead stopped on this - yet I have no trouble at all with Tomcat
>4.0.4.
>
>It seems like some people do get this to work.  It seems like many,
>many people do not.  Is there a bug at play in all this?
>
>Here's my question - Why is it so hard?
>
>--
>The ODS Companies
>Jeff Sexton
>Information Services
>(503) 228-6554   x1026
>http://www.odscompanies.com
>
>This message is intended for the sole use of the individual and entity
>to whom it is addressed, and may contain information that is
privileged,
>confidential and exempt from disclosure under applicable law. If you
are
>not the intended addressee, nor authorized to receive for the intended
>addressee, you are hereby notified that you may not use, copy, disclose
>or distribute to anyone the message or any information contained in the
>message. If you have received this message in error, please immediately
>advise the sender by reply email and delete the message.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business
communication, and may contain information that is confidential, proprietary
and/or privileged.  This e-mail is intended only for the individual(s) to
whom it is addressed, and may not be saved, copied, printed, disclosed or
used by anyone else.  If you are not the(an) intended recipient, please
immediately delete this e-mail from your computer system and notify the
sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



**********************************************************************
This email message has been swept by
MIMEsweeper for the presence of computer viruses.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message