From: Markus Schaber <schabi@logix-tt.com>
To: Nico <nicohmail-postgresql@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: mysql/posgresql pooling
Date: Tue, 03 May 2005 19:13:50 +0200
Message-ID: <4277B14E.5000500@logix-tt.com> (raw)
In-Reply-To: <d57s87$oth$1@news.hub.org>
References: <d57s87$oth$1@news.hub.org>
Hi, Nico,
Nico wrote:
> Hi, I run a servlet that runs on a Resin 3.0.2-webserver with MySQL and
> PostgreSQL database server.
> Operating system is Red Hat Enterprise Linux ES release 3 (Taroon Update 4).
> Resin uses its own pooling mechanism. I can make normal connections through
> both MySQL and PostgreSQL. However, when I try to get a connection from a
> pool, only MySQL connections are returned. How do I tell my servlet it needs
> a PostgreSQL connection instead of MySQL?
How do you communicate with the pool? I do not know anything about the
Resin interfaces, but in jboss, you use jndi to look up your datasources
by a datasource name, and have *-ds.xml files that define the
datasources (map name to driver class, host name, port, username and
other connection properties).
To get a PostgreSQL connection, you need do deploy the appropriate
definition in one of your *-ds.xml files, and then use this name when
looking up your datasource.
You do this along the lines of:
import java.sql.Connection;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class example {
public static Connection getConnection(String name) throws Exception {
InitialContext ic = new InitialContext();
DataSource dataSource = (DataSource) ic.lookup(name);
return dataSource.getConnection();
}
}
HTH,
Markus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: schabi@logix-tt.com, nicohmail-postgresql@yahoo.com
Subject: Re: mysql/posgresql pooling
In-Reply-To: <4277B14E.5000500@logix-tt.com>
References: <d57s87$oth$1@news.hub.org> <4277B14E.5000500@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox