Time for action – setting a JNDI/JDBC connection pool
We will now create a JDBC connection pool, which will be available via JNDI. Within our project, we will create an XML file and edit it to contain information about the previously mentioned pool. Finally, we will copy MySQL's JDBC driver into our project.
- We will head to the Project Explorer panel, which is located on the left of the UI, and navigate through prd5ch14 | WebContent | META-INF; once there, we will go to New | Other... and lastly select XML | XML File. We will then click on Next >, save the file with the name
context.xml
, and click on Finish to continue. - Once the XML file is created, we will automatically be presented with an XML editor in the central part of the UI. We will click on the Source tab to edit our code as shown in the following screenshot:
- We will now enter the following XML code into our file:
<?xml version="1.0" encoding="UTF-8"?> <Context> <Resource auth="...