When using connections pools available through jndi, you don’t need the
Rails 2.2 pool.
Just set the jndi name for the connection pool you want to use (that is
also
configured in your container), in the database.yml:
production:
adapter: jdbcmysql
for jetty
jndi: java:comp/env/jdbc/Pool
for tomcat
jndi: java:/comp/env/jdbc/Pool
And don’t forget to set the jndi reference in you web.xml:
jdbc/Pool
java​x.sql.DataSource<​/res-type>
Cont​ainer
Warbler already does it for you (generating the web.xml file with the
required lines):
Warbler::Config.new do |config|
…
config.webxml.jndi = ‘jdbc/Pool’
end
The last thing is that you must be sure that connections are being
returned
to the pool, at the end of request processing. I believe jruby-rack
isn’t
doing it automatically anymore in the last release (0.9.2), so you will
have
to add an after_filter to your application controller:
class ApplicationController < ActionController::Base
after_filter :close_all_connections
…
private
def close_all_connections()
ActiveRecord::Base.clear_active_connections!
end
end
Just one little tip: I’ve seen many times people having problems with
DBCP
and dead/timed-out connections. Try using something else (and better)
like
c3p0.
On Sat, Nov 22, 2008 at 8:25 PM, AD [email protected] wrote:
[email protected]> wrote:
And anything else you want to add.
–
Fabio K.
Caelum - Ensino e Inovação