Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 848 Bytes

File metadata and controls

22 lines (16 loc) · 848 Bytes

About

Quickstart repo for a Maven managed dynamic web-application using Servlets and JDBC.

DataSource

Before deploying to a webserver create a Resource like in your webserver's config (e.g. for Apache Tomcat in conf/context.xml).

<Resource name="jdbc/couponStore"
          type="javax.sql.DataSource"
          username="postgres"
          password="admin"
          driverClassName="org.postgresql.Driver"
          url="jdbc:postgresql://localhost:5432/coupon_store"
          closeMethod="close"/>

Note: the closeMethod="close" attribute is important. As per Tomcat's documentation this ensures that connections retrieved from the datasource are closed properly when a webapp context is reloaded/restarted/redeployed/etc.