...
Don't forget that all JNDI resources can be configured in a jetty.xml file (where they are available to all webapps) or in a WEB-INF/jetty-env.xml file where they will be available only to the declaring webapp. The following xml snippets can be inserted into either file. More information on that can be found here.
| Anchor | ||
|---|---|---|
|
Pooling DataSources
Enables connection pooling.
Connection pooling is basically re-using existing connections instead of creating a new connection to the database.
This would be highly efficient in terms of memory allocation and speed of the request to the database.
In production, this is highly recommended.
c3p0 (connection pooling)
...
Atomikos 3.3.2+ (connection pooling + XA transactions)
| Code Block | ||
|---|---|---|
| ||
<New id="DSTest" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jdbc/DSTest</Arg> <Arg> <New class="com.atomikos.jdbc.AtomikosDataSourceBean"> <Set name="minPoolSize">2</Set> <Set name="maxPoolSize">50</Set> <Set name="xaDataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</Set> <Set name="UniqueResourceName">DSTest</Set> <Get name="xaProperties"> <Call name="setProperty"> <Arg>url</Arg> <Arg>jdbc:mysql://localhost:3306/databasename</Arg> </Call> <Call name="setProperty"> <Arg>user</Arg> <Arg>some_username</Arg> </Call> <Call name="setProperty"> <Arg>password</Arg> <Arg>some_password</Arg> </Call> </Get> </New> </Arg> </New> |
| Anchor | ||
|---|---|---|
|
Non-pooling DataSources
If you're deploying in production environment, use the #Pooling DataSources instead.
MySQL
implements javax.sql.DataSource, javax.sql.ConnectionPoolDataSource
...