Blog Archive for January 20, 2011

Django Multi Database

January 20, 2011

Django allows you to connect to multiple databases.

Definition

Replace the existing database connection details in settings.py with

DATABASES = {
  'default' : {
    'NAME': 'wamdev',
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'USER': 'user',
    'PASSWORD': 'password',
    'HOST' : 'server',
    'PORT' : '5432',
  },
  'integration' …

Tracing Unclosed Database Connections in Tomcat DBCP

January 20, 2011

You can get Tomcat to output details of unclosed database connections, by configuring the data source using logAbandoned

Here's example config:

<Resource auth="Container" 
  name="jdbc/DataSourceName" 
  type="javax.sql.DataSource" 
  url="jdbc:hsqldb:hsql://localhost:9820/database" 
  password="" 
  maxActive="4" 
  maxWait="5000" 
  driverClassName="org.hsqldb.jdbcDriver" 
  username="sa" 
  maxIdle="2"
  removeAbandoned="true"
  removeAbandonedTimeout="60"
  logAbandoned="true" />

I …