commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vinicius Carvalho <vinicius.carva...@sambatech.com.br>
Subject Question on JNDI and DBCP
Date Wed, 18 Nov 2009 13:01:29 GMT
Hello there! I'm trying to register multiple datasources on the JNDI using
DBCP

Here's what I've done:

Reference refA = createRef(url,user,pwd);
Reference refB = createRef(url2,user2,pwd2);



ic.bind("java:/comp/env/jdbc/db1",refA);
ic.bind("java:/comp/env/jdbc/db2",refB);


private reference createRef(String url, String username, String password){

 Reference ref = new Reference("javax.sql.DataSource",
    "org.apache.commons.dbcp.BasicDataSourceFactory", null);
  ref.add(new StringRefAddr("driverClassName",
"org.apache.commons.dbcp.TesterDriver"));

  ref.add(new StringRefAddr("url", url));
  ref.add(new StringRefAddr("username", username));
  ref.add(new StringRefAddr("password", password));
  return ref;




}

The problem is that both context references points to the first datasource.
I thought that the JNDI would use the name part to bind a unique value, but
seems that both references turn to be the same (they both are
javax.sql.Datasource, BasicDatasourceFactory).

My question is how can I add multiple datasources under diferent jndi
locations?

Regards

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message