Should I mention the archive name in the Resource tag?

To connect to the derby database using Tomcat , I downloaded the Apache Derby database engine core jar (version: 10.9.1.0) . I saved this jar file in the lib folder in Tomcat.

enter image description here

Now I was told to add the following to Tomcat context.xml .

 <Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource" driverClassName="org.apache.derby.jdbc.EmbeddedDriver" url="jdbc:derby://localhost:1527/polldatabase;create=true" username="suhail" password="suhail" maxActive="20" maxIdle="10" maxWait="-1" /> 
  • What does this tag do? I mean, what is it for?

  • Although the downloaded Jar file contains the org.apache.derby.jdbc.EmbeddedDriver template, where in this tag do I mention the jar I downloaded? Do I need to add a tag name to a tag?

0
source share
1 answer

As soon as you put the jar in the Tomcat lib folder, Tomcat will automatically download it and place it in the class path so that all applications running on Tomcat know about this jar.

An XML definition simply means that you have defined a data source. The data source is used on application servers to manage database connection pools, so you don’t need to, this is the preferred method instead of plain JDBC.

In the xml that you defined: driverClassName="org.apache.derby.jdbc.EmbeddedDriver" , and since you put the jar driver that contains this class, in the lib folder it will know where to look for it, without indicating where it is bank.

Please note that placing a flag under Tomcat lib is not always the best solution, because, as I said, all applications under tomcat will know about this bank, and if there is an application that already uses this bank with a different version, it can cause conflicts .

The best solution would be to install jar under WEB-INF / lib, and only this application knows about the bank.

+3
source

Source: https://habr.com/ru/post/920199/


All Articles