0

I would like what is the best way to read N resources defined in tomcat server.xml file.

Currently to read a single resource:

<Resource name="jdbc/xxx"
          global="jdbc/xxx"
          auth="Container"
          type="javax.sql.DataSource"
          driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@xxx.it:1521:orcl"
          username="XXX"
          password="XXXX"
          maxIdle="20"
          minIdle="5" />

i used this code:

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

is there a way to configure multiple Resource in the server.xml file and then read a list of them?

Sorry for the english

  • You can add as many `` and [``](https://tomcat.apache.org/tomcat-9.0-doc/config/context.html#Environment_Entries) entries as you wish and list them all in your code. – Piotr P. Karwasz Sep 15 '21 at 03:56

0 Answers0