Creating datasources and a connection pool

To create a datasource and a connection pool to help you use databases in your project, edit the $TOMEE_HOME/conf/tomee.xml file.

Inside the <tomee> node, insert a child node like this one:

  <Resource id="MyDataSouceDs" type="javax.sql.DataSource">      jdbcDriver = org.postgresql.Driver      jdbcUrl = jdbc:postgresql://[host]:[port]/[database]      jtaManaged = true      maxActive = 20      maxIdle = 20      minIdle = 0      userName = user      password = password  </Resource>

The example targets PostgreSQL, so you will need to perform some changes for another database. Of course, you will also need to change the other parameters according to your needs.

Get Java EE 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.