Using an embedded SQL database in Java web application
You have a Java web application needing a relational SQL database. According to JavaEE conventions, you declare the DataSource in web.xml:
<resource-ref>
<res-ref-name>jdbc/DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and then fetch it in code with (DataSource)new InitialContext().lookup("java:comp/env/jdbc/DS").
Using Maven, Jetty and HSQLDB, you can very easily run the web application for local testing without having to setup neither a web container, nor a database. Add this to pom.xml: