This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes java.sql.SQLException: You cannot set autocommit during a managed transaction! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Reply locked New topic

java.sql.SQLException: You cannot set autocommit during a managed transaction!

Vijay Aneraye

Joined: Sep 03, 2008
Posts: 8
Hello Friends,
I'm using a Datasource connection configured in xxx-ds.xml of Jboss Server. And used method setAutoCommet(false) after getting connection.Due to this i received the error of "java.sql.SQLException: You cannot set autocommit during a managed transaction!"

My datasource file is
<!-- should only be used on drivers after 3.22.1 with "ping" support
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->

And My Connection Code is

String dsName = dataSource;
try {
/* get data source by lookup in initial context */
ds = (DataSource)MSPUtility.getInitialContext().lookup(dsName);
conn = ds.getConnection();
/*set AutoCommited False*/

catch (Exception e) {
.println("[Error][MSPDal]: Falied while getting datasource connection: "
+ dsName);


Can you please help me to resolved this issue.

Vijay Aneraye
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 43381
Welcome to JavaRanch ( ) but please don't post what appears to be the same question twice.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32319

I'll close this copy so we can continue discussion in one place

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: java.sql.SQLException: You cannot set autocommit during a managed transaction!
It's not a secret anymore!