Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the <a href="http://grails.org/doc/2.0.0.M2/guide/conf.html#multipleDatasources" rel="nofollow noreferrer">corresponding documentation</a>. This blog <a href="http://burtbeckwith.com/blog/?p=312" rel="nofollow noreferrer">provides a code example</a> how to delay DataSource creation in Grails... and it is possible to use C3P0 in such a code.</p> <p>As Grails comes with DBCP by default, I do not find relevant to add code to setup C3P0 pooling (and later replace the default transaction manager...) when it is possible to delegate <code>DataSource</code> and pooling configuration to the underlying container, for instance Tomcat or JBoss. So I recommend that way of doing and here is an example <a href="https://stackoverflow.com/questions/5246874/using-c3p0-connection-pooling-in-a-tomcat-spring-based-app">how to setup C3P0 for a Tomcat DataSource</a>, just add its jar in <code>lib</code> directory.</p> <p>Now, when configuring multiple DataSources, you should take care to the section about the lacking two-phase-commit support in Grails.</p> <p>If you expect operations done on connections from your two DataSource to be included in a single transaction (commit on both if success, rollback on both if failure), you will have to use a XA transaction manager.</p> <p>In that case, I recommend you to deploy in JBoss and <a href="https://community.jboss.org/wiki/DataSourceConfigurationInAS7" rel="nofollow noreferrer">configure DataSources and pooling in JBoss</a> itself, the JDBC driver must be installed in JBoss libraries.</p> <p>You will get benefits of the included XA transaction manager. On Grails side, the DataSource is configured to query a JNDI <code>resource-ref</code> entry declared in <code>WEB-INF/web.xml</code> and <code>WEB-INF/jboss-web.xml</code> files of your WAR file.</p> <pre><code>dataSource { jndiName = "java:comp/env/myDataSource" } </code></pre>
 

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