From: | Markus Schaber <schabi(at)logix-tt(dot)com> |
---|---|
To: | Nico <nicohmail-postgresql(at)yahoo(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: mysql/posgresql pooling |
Date: | 2005-05-03 17:13:50 |
Message-ID: | 4277B14E.5000500@logix-tt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2005-05-03 17:43:39 | Re: mysql/posgresql pooling |
Previous Message | Zachery Jensen | 2005-05-03 16:33:15 | Re: mysql/posgresql pooling |