Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://download.oracle.com/otn-pub/jcp/jdbc-4_1-mrel-spec/jdbc4.1-fr-spec.pdf?AuthParam=1372927466_cbe87f23984cc080f4d3cb9e65e97117">JDBC spec</a> states that, "The default is for auto-commit mode to be enabled when the Connection object is created." That's a cross DBMS default, regardless of how the database behaves in other contexts. JDBC programmers may rely on autoCommit being set unless they explicitly call <code>setAutoCommit( false )</code>. c3p0 honors this.</p> <p>c3p0 allows ConnectionCustomizers to persistently override Connection defaults in the <code>onAcquire()</code> method when the no single behavior is specified. For example, the spec states that "The default transaction level for a Connection object is determined by the driver supplying the connection." So, for transactionIsolation, if you reset that in <code>onAcquire(...)</code>, c3p0 will remember the default you have chosen, and always restore the transactionIsolation back to that default prior to checkout. However, c3p0 explicitly will not permit you to disable <code>autoCommit</code> once in <code>onAcquire(...)</code> and have <code>autoCommit</code> be disabled by default. at the moment of check-out, c3p0 insists you have a spec conformant Connection.</p> <p>You can get the behavior that you want by overriding the <code>onCheckOut(...)</code> method. The Connection is already checked-out when <code>onCheckOut(...)</code> is called, you can do anything you want there, c3p0 has exhausted it obligations to the specification gods at that point. If you want your clients to always see non-autoCommit Connections, call <code>setAutoCommit( false )</code> in <code>onCheckOut(...)</code>. But do beware that this renders your client code unportable. If you leave c3p0 and switch to a different DataSource, you'll need to use some other library-specific means of always disabling <code>autoCommit</code> or else you'll find that your application misbehaves. Because even for postgres, JDBC Connections are <code>autoCommit</code> by default.</p> <p><strong>Note:</strong> The Connection properties whose values are not fixed by the spec and so can be persistently overridden in an <code>onAcquire(...)</code> method are <code>catalog</code>, <code>holdability</code>, <code>transactionIsolation</code>, <code>readOnly</code>, and <code>typeMap</code>.</p> <p>p.s. <em>don't</em> set <code>forceIgnoreUnresolvedTransactions</code> to <code>true</code>. yuk.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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