2 Replies Latest reply on Feb 7, 2013 6:40 PM by Murray9654

    Connection pool and Context

      i am working on netbeans IDE , but I understand how the aplication know the paremetres for the conections i undertand what is a Context , specifically i understand this code about the init method

      Context initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");

      servicioConexiones = (DataSource) envCtx.lookup("jdbc/bd_tutorias");

      I want to know how the application knows to use these connection parameters, on the Context.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <Context antiJARLocking="true" path="/tutorias_pag480">
      <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
      maxActive="8" maxIdle="4" name="jdbc/bd_tutorias" password="mysqladmin"
      type="javax.sql.DataSource" removeAbandoned="true"
      url="jdbc:mysql://localhost:3306/bd_tutorias" username="root"/>
        • 1. Re: Connection pool and Context
          It is more the container that is knowing which settings to use. The container understands the Context.xml (it's structure was determined by the container authors) and every time you do
          new InitialContext();
          in your application the container will create a context object that has ability to look up many things configured inside the container. In your xml file you specified
          <Resource auth="Container" ... name="jdbc/bd_tutorias" password...
          so the container makes available a context object that is capable of looking up the resource that you named above.
          • 2. Re: Connection pool and Context
            i don't think that the resource in xml is a jndi configaration. I think it is the configaration for data source. data source uses that configaration to connect to the database to fetch the data. It is no way related to context, I mean jndi.