Re: mysql/posgresql pooling

Поиск
Список
Период
Сортировка
Искать
От
Markus Schaber
Тема
Re: mysql/posgresql pooling
Дата
в 14:16:43
Msg-id
4277B14E.5000500@logix-tt.com
Ответ на
Список
Дерево обсуждения
Re: mysql/posgresql pooling "Nico" <nicohmail-postgresql@yahoo.com>
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
В списке pgsql-jdbc по дате отправления
От: Zachery Jensen
Дата:
Сообщение: Re: mysql/posgresql pooling
От: John R Pierce
Дата:
Сообщение: Re: mysql/posgresql pooling
FAQ