tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <mil...@gmx.de>
Subject Re: Re: Tomcat 6 unstable
Date Tue, 25 Nov 2008 02:50:24 GMT
Jabali Acuatico schrieb am 24.11.2008 um 18:02:23 (-0800):
> I read the link you posted me, but the comments in the
> catalinal.properties has no example with "file:///" so I did not write
> like this. I added to this line the path to the db2 jdbc driver. The
> current sentence is this one:
> common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar,/opt/java/jdk/jre/lib/ext/*.jar
> 
> ¿Is this right or do I need to include "file:///"?

I've read somewhere that omitting the file:/// URI scheme is wrong.
However, it seems to work. At least on Windows. In order to be on the
safe side, you should add the "file:///" URI scheme.

> > 2) About an earlier Tomcat: I just downloaded the 6.0.18 version and
> > catalina.sh it's running ok (but I have not put my webapp there
> > yet). 
> 
> Careful! :-)
> I did that because one of you recommend me to do that.  Why do you
> say careful?

Not to be taken seriously. Your web app and container configuration
editing seemed to have the potential of ridding the container of the
Servlet API (like the car of its wheels), so I said "careful", but I
didn't mean it.

> Thanks for all. Now I need to learn how to do a pooling of
> connections. Any comments?

Read the documentation for Tomcat 6:

http://localhost:8080/docs/jndi-resources-howto.html
http://localhost:8080/docs/jndi-datasource-examples-howto.html

Read the documentation for DBCP, which is the connection pooling
implementation Tomcat 6 uses as of now:

http://commons.apache.org/dbcp/configuration.html

Configure the resource in "conf/context.xml".

 <Resource name="jdbc/firebird/test"
  auth="Container"
  type="javax.sql.DataSource"
  driverClassName="org.firebirdsql.jdbc.FBDriver"
  username="bla" password="blub"
  url="jdbc:firebirdsql:localhost:test"/>

Initially, you don't need to configure the pool. You can accept the
defaults for initialSize, maxActive, maxIdle, minIdle and maxWait.

Then refer to the JNDI name in your application like so:

DataSource ds = null;
try {
    Context initCtxt = new InitialContext();
    Context envCtxt = (Context) initCtxt.lookup("java:comp/env");
    ds = (DataSource) envCtxt.lookup("jdbc/firebird/test");
}
catch ( NamingException ne ) {
    ...
}
Connection conn = ds.getConnection();
...

As the Tomcat documentation says, it is important to explicitly close
result sets and statements. Why is this important?

If your connection is closed, either explicitly or implicitly by going
out of scope, all objects derived from it are also closed. (That's how
drivers are implemented so they're not too complicated to use.)

The whole point of the pool, however, is to *not* close the connection.
So no automatic tidying up is going to happen: you have to do it
yourself.

Michael Ludwig

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message