Créer une référence JNDI sur une BasiDataSource









      InitialContext ic = new InitialContext();
      // Construct BasicDataSource reference
      Reference ref = new Reference("javax.sql.DataSource",
          "org.apache.commons.dbcp.BasicDataSourceFactory", null);
      ref.add(new StringRefAddr("driverClassName", "org.postgresql.Driver"));
      ref.add(new StringRefAddr("url",
          "jdbc:postgresql://localhost:5432/postgres"));
      ref.add(new StringRefAddr("username", "postgres"));
      ref.add(new StringRefAddr("password", "postgres"));
      ref.add(new StringRefAddr("maxActive", "4"));
      ref.add(new StringRefAddr("maxWait", "5000"));
      ref.add(new StringRefAddr("removeAbandoned", "true"));
      ref.add(new StringRefAddr("removeAbandonedTimeout", "5000"));
      ic.rebind("jdbc/Silverpeas", ref);



Java2html


Posted in Libellés : , |

0 commentaires: