Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>Is there a standard way to define a JDBC datasource and deploy it?</p> </blockquote> <p>Yes, there is. It's done via the <code>&lt;data-source&gt;</code> element, which you can put in <code>web.xml</code>, <code>ejb-jar.xml</code> and <code>application.xml</code>. If you don't like XML, you can also use an annotation for this instead: <a href="http://docs.oracle.com/javaee/6/api/javax/annotation/sql/DataSourceDefinition.html" rel="noreferrer">@DataSourceDefinition</a></p> <p>Example of a web.xml entry</p> <pre><code>&lt;data-source&gt; &lt;name&gt;java:app/myDS&lt;/name&gt; &lt;class-name&gt;org.postgresql.xa.PGXADataSource&lt;/class-name&gt; &lt;server-name&gt;pg.myserver.com&lt;/server-name&gt; &lt;database-name&gt;my_db&lt;/database-name&gt; &lt;user&gt;foo&lt;/user&gt; &lt;password&gt;bla&lt;/password&gt; &lt;transactional&gt;true&lt;/transactional&gt; &lt;isolation-level&gt;TRANSACTION_READ_COMMITTED&lt;/isolation-level&gt; &lt;initial-pool-size&gt;2&lt;/initial-pool-size&gt; &lt;max-pool-size&gt;10&lt;/max-pool-size&gt; &lt;min-pool-size&gt;5&lt;/min-pool-size&gt; &lt;max-statements&gt;0&lt;/max-statements&gt; &lt;/data-source&gt; </code></pre> <p>Further reading:</p> <ul> <li><a href="https://weblogs.java.net/blog/lancea/archive/2009/12/10/introducing-datasourcedefinition-annotation" rel="noreferrer">Introducing the DataSourceDefinition Annotation</a></li> <li><a href="http://henk53.wordpress.com/2012/06/30/the-state-of-datasourcedefinition-in-java-ee" rel="noreferrer">The state of @DataSourceDefinition in Java EE</a></li> <li><a href="http://jdevelopment.nl/open-source/java-ee-kickoff-app" rel="noreferrer">Example application use standard data source</a></li> </ul> <p><em>p.s. I'm surprised all other answers say this doesn't exist, while it clearly does, even at the time this question was originally asked.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload