In this section, we will open the project and update the database connectivity configuration, then launch the project in the local development environment to test that the project is building and connecting to the database correctly.
You will need to wait for Maven to pull down all the required project packages. The completion percentage will be displayed in the bottom right corner.
<beans:bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"
destroy-method="close">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="${JDBC_CONNECTION_STRING}" />
<beans:property name="username" value="${JDBC_UID}" />
<beans:property name="password" value="${JDBC_PWD}" />
<beans:property name="jdbcInterceptors" value="com.amazonaws.xray.sql.mysql.TracingInterceptor" />
</beans:bean>
Do not edit this code, but note that this code uses environment variables to configure the server and username/password to a MySQL database. When you execute this code on the server, these environment variables allow you to, at execution time, access the correct server.
You must set these environment variables or the application will fail.
In this lab you will set these variables to allow local execution with remote access to the RDS instance running the TravelBuddy database. Later after you transfer to the application to AWS Elastic Beanstalk, you will learn how to set these variables as configuration parameters in the Elastic Beanstalk environment.
You may need to use the Other… feature to select the Servers view if it is not offered in the initial listing.
C:\ProgramData\Tomcat9
<!-- Environment variables -->
<Parameter name="JDBC_CONNECTION_STRING" value="jdbc:mysql://<RDSEndpoint>:3306/travelbuddy?useSSL=false" override="false"/>
<Parameter name="JDBC_UID" value="root" override="false"/>
<Parameter name="JDBC_PWD" value="labpassword" override="false"/>
Change < RDSEndpoint> by RDS endpoint
If you don’t see the option of Run on Server, right click on your project folder, click Maven, click Update Project… and click OK.