Skip to main content

defaultAutoCommit and JDBC Connection Pool

3 replies [Last post]
m_jenkins
Offline
Joined: 2009-09-25

Hi,

I am using Glassfish 2.1 with ESB.

When I do my development on my laptop, I find that I cannot use Glassfish JDBC Connection Pools, as for some reason a full Glassfish restart is required every time I redeploy a WAR that uses the pools.

So when working locally I don't use Glassfish connection pooling, but instead use Spring connection pooling.

Spring works nicely with the property defaultAutoCommit=false.

I can then invoke stored procedures, which are written such that they only do a final COMMIT if everything works.

My problem is that when I deploy to the target Solaris Glassfish environment, and I switch to using the Glassfish connection pooling, the stored procedures that I call ALWAYS get committed.

This is the data source bean:

This is the bit from my domain.xml that defines the connection pool:

Can anybody help me? What am I doing incorrectly?

Thank you very much!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Martin Gainty

not in the declarators but you can disable Autocmmit by setAutoCommit(false) on the acquired connection handle e.g.

Compiled from "Connection.java"
public interface java.sql.Connection extends java.sql.Wrapper{
public abstract void setAutoCommit(boolean) throws java.sql.SQLException;
........
}
conn.setAutoCommit(false);

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> Date: Fri, 23 Apr 2010 08:44:43 -0700
> From: glassfish@javadesktop.org
> To: users@glassfish.dev.java.net
> Subject: defaultAutoCommit and JDBC Connection Pool
>
> Hi,
>
> I am using Glassfish 2.1 with ESB.
>
> When I do my development on my laptop, I find that I cannot use Glassfish JDBC Connection Pools, as for some reason a full Glassfish restart is required every time I redeploy a WAR that uses the pools.
>
> So when working locally I don't use Glassfish connection pooling, but instead use Spring connection pooling.
>
> Spring works nicely with the property defaultAutoCommit=false.
>
> I can then invoke stored procedures, which are written such that they only do a final COMMIT if everything works.
>
> My problem is that when I deploy to the target Solaris Glassfish environment, and I switch to using the Glassfish connection pooling, the stored procedures that I call ALWAYS get committed.
>
> This is the data source bean:
>
>
>
>

>
> This is the bit from my domain.xml that defines the connection pool:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
> Can anybody help me? What am I doing incorrectly?
>
> Thank you very much!
> [Message sent by forum member 'm_jenkins']
>
> http://forums.java.net/jive/thread.jspa?messageID=398695
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:...
[att1.html]

m_jenkins
Offline
Joined: 2009-09-25

Ah thanks very much Martin for replying.

Interesting to hear that you cannot set autoCommit to false in the configuration.

This is my init:

protected void init() {
if (initDone) {
return;
}

dataSource = (DataSource)ctx.getBean("dataSource");
initDone = true;
}

... and then a bit later on I go on to create a org.springframework.jdbc.object.StoredProcedure object, and pass it the dataSource. The StoredProcedure object then goes on to do the getConnection() itself.

Am I stuck up a creek?

Do I need to rewrite the way things are done?

Or maybe get the DBA to rewrite the stored procedures, so they don't rely on defaultAutoCommit being set to false.

Message was edited by: m_jenkins

m_jenkins
Offline
Joined: 2009-09-25

I've decided to change all the SPs to explcitly Rollback or Commit.

Clearly this has implications on multi-SP transactions (i.e. we can't have them!)

If anybody knows if we [i]should [/i]be able to configurably set defaultAutoCommit on glassfish for an Oracle db pool, I'd love to know!

Thank you