ExecuteBatch commits despite autocommit(false)

Hello !
Can someone explain the jdbc-spec to me ?
Should executeBatch commit the transcations if no excpetion was
thrown ?
It seems that the oracle-driver does commit after executeBatch.
I don't think this is right (according to the jdbc-spec) and for us it
is really annoying since we wanted to use a temporary table
with "on commit delete rows". which has the effect, that the table
is empty after inserting with executeBatch (very clever).
The temporary table with "on commit preserve rows" works fine.
Thanks

it is my impression that if autocommit is set to false, and no con.rollback() was issued before the program exits, the drivers call an automatic con.commit() before it closes the connection(I've experienced this consistently with 4 different databases). But this probably is not in the java jdbc specs, but a driver implementation decision depending on the vendor/driver.
does anyone else know more on the specs?
Jamie

Similar Messages

  • SendBatch commits with AutoCommit false

    Is there a way to make sendBatch NOT commit a batch until
    commit() is called? I need to call sendBatch to get an accurate
    rowcount, so I can't just let commit implicitly call sendBatch.
    null

    it is my impression that if autocommit is set to false, and no con.rollback() was issued before the program exits, the drivers call an automatic con.commit() before it closes the connection(I've experienced this consistently with 4 different databases). But this probably is not in the java jdbc specs, but a driver implementation decision depending on the vendor/driver.
    does anyone else know more on the specs?
    Jamie

  • How to set autocommit false in Oracle Weblogic console?

    Hi All,
    While invoking the oracle Ebiz custom package from Oracle SOA 11g BPEL we are getting below error:-
    java.sql.SQLSyntaxErrorException: ORA-02089: COMMIT is not allowed in a subordinate session.
    Wondering if there is some properties through which we can set the autocommit false on the Oracle Weblogic Console.
    Highly appreciate any pointers for the same.
    Thanks in advance.

    Yes I did set global transaction (XA) up in the db adapter. True, there are couple of commits in the API and from outside BPEL that works fine, the error i am getting when trying to access the API through BPEL. I am calling this only API from the BPEL.
    Do you think there needs to setup explicit "autoCommit=false" somewhere in the weblogic console?

  • How set autocommit=false with container transactions?

    Hi all!
    A'm using EJB's with transaction attribute=Container.
    This is simple scenario:
    call Session Bean
    begin transaction
    call EntityBean1 {
    database update 1
    call EntityBean2 {
    database update 2
    end transaction
    return from session bean
    The problem is:
    when update2 fails update1 not rolling back.
    A know, that solution of this problem is set AUTOCOMMIT=FALSE in Connection, but how do this with container transactions? Point me exactly to place, where this can be done, if this possible. Or may be no general solution (I.e. Each case demands it's own approach.)?
    (I can't directly call method of Connection object because of transaction managed by container)
    Tnx a lot.

    Hi there,
    I have the same problem with Orion and NuSphere MySql.
    When I define a container-managed transaction, the autocommit mode is not changed.
    I have a session bean for which I set the transaction attribute to REQUIRED and two entity beans for which the transaction attribute is SUPPORTS in the ejbjar.xml file.
    The session beans calls the two entity beans and makes some modifications on them like for instance removing them from the database.
    When I check whether a transaction can be rolled back, for instance by putting in my code a loop that never ends and then stopping the server, it seems my application is running in autocommit mode. No rollback is done.
    This is very strange.
    The two entity beans are stored using gemini tables which permit rollbacks. So when I start a transaction inside mySql using sql statements, I can do a rollback without problem.
    Any idea of what's going wrong ?
    Dimitri.

  • ExecuteBatch commits even if autocommit is false ?

    Hello !
    Is it true that executeBatch (e.g on PreparedStatement) commits
    the changes after running ? We tried using a temporary table
    with on "commit delete rows" and fill this table with
    executeBatch().
    The following Statements seem to find this table empty.
    Using normal tables or on commit preserve rows works.
    OF course autocommit is false and the temporary table is used
    on the same connection.
    If it is true, does this violate the jdbc-spec ?
    Tested with 8.1.7 Database on sparc and the classes12.zip from
    9.0.1
    Thanks

    SMB 3 in Windows Server 2012 adds the capability to make data transfers secure by encrypting data in-flight, to protect against tampering and eavesdropping attacks. The biggest benefit of using SMB Encryption over more general solutions (such as IPSec) is
    that there are no deployment requirements or costs beyond changing the SMB Server settings.
    http://blogs.technet.com/b/filecab/archive/2012/05/03/smb-3-security-enhancements-in-windows-server-2012.aspx
    http://technet.microsoft.com/en-us/library/jj635714.aspx
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • JDBC Thin Driver Won't Honor Autocommit=FALSE

    I have the following code, which intializes a JDBC thin driver connection, and sets the autocommit to false. However, as soon as the statement is executed, it commits on its own. What's going wrong here? I can tell that it is committing, because the calendar events all disappear, even if the code is terminated before committing, or in an endless loop.
    odsSecondary = new OracleDataSource();
    odsSecondary.setDatabaseName("####");
    odsSecondary.setDriverType("thin");
    odsSecondary.setUser("####");
    odsSecondary.setPassword("####");
    odsSecondary.setPortNumber(1521);
    odsSecondary.setServerName("####");
    connectionSecondary = odsSecondary.getConnection();
    connectionSecondary.setAutoCommit(false);
    Statement stmtSecondary = connectionSecondary.createStatement();
    stmtSecondary.executeUpdate("truncate table cal_events");

    The truncate command always issues a commit. refer to the oracle SQL documentation

  • Autocommit == false; close(); // what happens?

    I'm currently writing a simple implementation of a DataSource which just wraps an exsiting Connection (Yeah, I know there are better ways for handling database connectivity - let's just say I'm forced to do so...).
    I want to make sure that whenever I return the connection, autocommit is set to true, as defined by JDBC.
    Now, suppose I have a previously used java.sql.Connection which autocommit value is set to false.
    I wan't to set autocommit to true now, but this would commit data of a connection which, from a meta-point of view, is already closed. Obviously, I would execute a rollback at this point.
    Okay, but maybe handling this autocommit stuff should be done when the connection is "closed", i.e. returned to my so-called pool. And here, I am not sure what to do. My point of view is to make a rollback also, but I'm not sure if this would be appropriate.
    All applications I know just ask you what to do in such cases. But this is surely not the thing I can do here, and I don't know of any default behaviour for this.
    So, does JDBC say anything about this scenario? I did not find anything related.
    The commons DBCP (http://jakarta.apache.org/commons/dbcp/) seems to ignore this issue.
    Thanks in advance,
    Sebastian

    Sir,
    >
    Noting of course that there is a specification for
    JDBC and one would normally write to that, not the
    java docs. Which is why I suggested using the spec.According to the JBDC 3.0 final spec section 10.1.1 page 62.
    When auto-commit is disabled, each transaction must be explicitly
    commited by calling the Connection method commit or else explicitly rolled back
    by calling the Connection method rollback.Which adds a certain vagueness to the whole thing if taken out of context of the whole point of transactions. So the question is what should happen if neither is done explictly? The answer must be to rollback as a commit would violate the nature of a transactional system since none was specifically requested.
    >
    And I believe there is also one driver that
    specifically does not do that. So relying on the
    driver for the default behavior, what ever it should
    be, probably isn't a good idea.If a driver or database does that IMO it is not a transactional database system or driver and certainly not one that follows the principles of ACID. If the database does that then I would be very wary of using transactions with the database. If the driver does that then I would get a new driver. May I ask what driver commits this horrible action on close?
    Sincerely,
    Slappy

  • Budget availability for commitement despite service entry acceptance

    Hi Experts
    I have WBS budget 1000 INR, Then created commitment for 1000 INR.
    Sbsequently I have service entry created and appoved.
    How ever, I have invoiced for 900 only.
    I wish to get the remaining 100 to be available for commitment for creation of new PO on a different vendor.
    Please advise the possible options
    Warm regards
    ramSiva

    Follwoing options are available
    - Block the purchase order item.
    - Reverse the existing service entry and create a new one with Final entery indicator set.
    - I it is a LIMIT service order, reduce the " Overall limit" to match the actual amount.
    Rajesh

  • Transaction context broken by Java Intermedia

    Hi, when I use java intermedia, my transactions seems to forced commited despite SetAutoCommit(false) command.
    Tx for any help.

    Can you post the code snippet? It's not supposed to be that way. We will have a better idea of what to look for if we can see the code.
    Larry

  • AutoCommit Issue

    Hello,
    I recently switched oracle drivers (using wls8.1, sp3 weblogic.jdbc.oracle.OracleDriver). I do an autoCommit(false), though it seems to ignore it. The executeUpdates seem to happen with no commit(). I actually had to remove the commit because i was getting an error like this:
    java.sql.SQLException: Cannot call Connection.commit in distributed transaction. Transaction Manager will commit the resource manager when the distributed transaction is committed.
    The oracle version is 8.1.7
    Any guidence would be great, should i be using the XA driver instead?
    Thanks!

    "James Bort" <[email protected]> wrote in message news:29237217.1095360506265.JavaMail.root@jserv5...
    I recently switched oracle drivers (using wls8.1, sp3 weblogic.jdbc.oracle.OracleDriver). I do an autoCommit(false), though itseems to ignore it. The executeUpdates seem to happen with no commit(). I actually had to remove the commit because i was getting
    an error like this:
    >
    java.sql.SQLException: Cannot call Connection.commit in distributed transaction. Transaction Manager will commit the resourcemanager when the distributed transaction is committed.
    >
    The oracle version is 8.1.7
    Any guidence would be great, should i be using the XA driver instead?James,
    Are you using TXDataSource? If yes, you should not try to control
    the commit mode - weblogic TX coordinator will do it for you. Let
    me know if you have more questions.
    Regards,
    Slava Imeshev

  • AutoCommit question, please help

    Environment: WLS6.1 SP2, Oracle 9i
    I wrote a test program to get a JDBC connection from TxDataSource, set the connection
    to AutoCommit false then call PrepareStatement.executeUpdate() to insert one row
    to database.
    I didn't call commit or rollback. At finally block I call close(). What is the
    expected result? My test result is, the row was added into database. Must I call
    rollback at the end if I hope the operation don't be committed?
    My JDBCConnectionPool setting looks like:
    Properties="user=amy;password=amy;dll=ocijdbc9;protocol=thin"
    URL="url=jdbc:oracle:thin:@127.0.0.1:1521:test"/>

    amyshuai wrote:
    Joseph Weinstein <[email protected]> wrote:
    AmyShuai wrote:
    Environment: WLS6.1 SP2, Oracle 9i
    I wrote a test program to get a JDBC connection from TxDataSource,set the connection
    to AutoCommit false then call PrepareStatement.executeUpdate() to insertone row
    to database.
    I didn't call commit or rollback. At finally block I call close().What is the
    expected result? My test result is, the row was added into database.Must I call
    rollback at the end if I hope the operation don't be committed?
    My JDBCConnectionPool setting looks like:
    Properties="user=amy;password=amy;dll=ocijdbc9;protocol=thin"
    URL="url=jdbc:oracle:thin:@127.0.0.1:1521:test"/>Hi. As a typical DBMS/JDBC user, if I did a partial transaction with
    an autoCommit(false)
    connection, and then closed the connection without committing, I would
    prefer
    the driver to protect me from the bad code by rolling back anything I
    abandoned.
    Most JDBC drivers/DBMSes will do that, but Oracle won't. You are getting
    Oracle's default behavior. Please verify this by doing the same, with
    a JDBC connection
    you get directly from the thin driver.
    Joe Weinstein
    Hi, Joe,
    Thanks for the reply. Is there any way to change Oracle default behavior?
    Thanks.No, sorry. Even from SQL-PLUS, if you exit out of SQL-PLUS with transactional stuff
    pending, it can get committed. The best solution is to code your JDBC in a try block, and
    have a finally block which makes sure to finish the transaction the way you want, and then
    close the connection.
    Joe

  • Pm.getConnection(), autocommit and transactions

    Hi everyone,
    I've got a problem with transactions not getting committed with runtime
    access to the JDBC connection through Kodo (see 4.9 of Dev Guide).
    I begin a transaction:
    pm.begin();
    I then get hold of the Connection, having ensured the transaction is
    active and is a datastore connection - see
    http://www.solarmetric.com/Software/Documentation/3.3.4/docs/javadoc/kodo/runtime/KodoPersistenceManager.html#getConnection()
    Connection conn = (Connection)pm.getConnection();
    I then execute a statement to delete all rows:
    Statement stmt = null;
    stmt = conn.createStatement();
    int rows = stmt.executeUpdate("delete from ACCOUNT");
    log.info("deleted "+rows+" ACCOUNT rows");
    // conn.commit();
    // conn.rollback();
    pm.commit();
    pm.close();
    If I call pm.commit(), the delete from ACCOUNT does not get committed and
    the rows are still there. I have to call conn.commit() to get it to
    commit. According to the docs, pm.commit() should work.
    If however I use the pm to first query an Account object and update it
    within the transaction, the rows are immediately removed from the database
    when I execute the statement, even before I commit the connection! Calling
    conn.rollback() instead has no effect! It is as though conn is not the
    connection that pm is using but a different one, one that has autocommit
    enabled if an object is updated in the pm's transaction. In fact looking
    at the connection that is returned in my debugger, the connection does
    indeed have autocommit=true. Surely the connection returned by Kodo should
    have autocommit=false?
    I don't have any funny transaction isolation level config in my
    kodo.properties. Any clues what's happening?
    Regards,
    Alex

    If you're using optimistic transactions, pm.begin() doesn't actually
    begin a transaction, and pm.commit() might not do anything if no
    object-level changes have taken place. So use a non-optimistic
    transaction.
    Kodo 4 also has a method KodoPersistenceManager.beginStore() to ensure
    that a datastore transaction is in effect, rather than you having to use
    a non-optimistic transaction.

  • KSB2 report: purchase order items have no commitment lines

    Hi, everybody!
    We switched on the Availability Control recently. We rebuilt the FM budget using transaction FMVB and we realised there is some information that appears on FM reports and not on CO reports.
    There is a purchase order that has been invoiced partially but does not appear the correspondent commitment lines appear on FM reports and not on CO reports.
    On fmrp_3fmb4004 report appears but on KSB2 report does not appear.
    Thanks in advance.
    Best regards

    Note 45122 is about reposting CO documents, and that is not our real problem.
    We have a purchase order with 3 items.
    Two of them work well: they have their cost center assignment and so the corresponding commitment amount
    But the third has not commitment, despite the fact it's exactly like the other ones.
    If we repost the CO document, we won't solve the problem. We'll just solve one item.
    Could it be related to a FM rebuilt budget we did using transaction FMVB?

  • How to disable AutoCommit at DataSource level for 9.2

    Hi,
    I am trying to persist my JMS messages into timesten datastore for which connection received from timesten needs to be with AutoCommit disabled.
    Any idea how to do it in Weblogic 9.2 admin console/JDBC data source level?
    Thanks,
    Alan

    Alan D wrote:
    Hi Joe,
    I am trying to persist jms messages into timesten datastore. This data store is configured for two safe replication which does not allow any operations with autocommit=true. Hence connection which is obtained by this datastore has to be set to autocommit=false before any sql commands.
    I have created persistent store as JDBC store which is mapped to JMS Server. I have tried to use JDBC datasource which supports global transactions as well as datasource which do not support global transaction for this persistent storage. But problem of autocommit still remains.
    Thanks,
    AlanThe restriction that a connection can never operate in autoCommit(true)
    mode is very unusual and against the JDBC spec. You should turn on
    JDBC logging and get us a full stack trace of the driver exception,
    to see where it is being used in the autoCommit(true) mode. By spec
    a driver will deliver a connection in autoCommit(true) mode.
    Joe

  • Exception: Can't call commit when autocommit=true

    Hello,
    I'm trying to use WebLogic 7.0 with MySQL 3.23.49 and MySQL Connector/J JDBC driver
    2.0.14. Everything has been working just fine but now I keep getting exception:
    java.rmi.RemoteException: EJB Exception:; nested exception is:
         javax.ejb.EJBException: EJB Exception: : javax.transaction.HeuristicMixedException:
    (weblogic.jdbc.jts.Connection, HeuristicHazard, (javax.transaction.xa.XAException:
    Can't call commit when autocommit=true))
         at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:258)
         at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:208)
         at weblogic.ejb20.internal.BaseEJBLocalHome.postHomeInvoke(BaseEJBLocalHome.java:314)
         at weblogic.ejb20.internal.EntityEJBLocalHome.findByPrimaryKey(EntityEJBLocalHome.java:289)
         at com.nokia.m2m.demo.housemanagement.ejb.HouseBean_15mjuo_LocalHomeImpl.findByPrimaryKey(HouseBean_15mjuo_LocalHomeImpl.java:137)
         at com.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean.ejbCreate(HouseManagerBean.java:326)
         at com.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_Impl.ejbCreate(HouseManagerBean_wnwfw3_Impl.java:117)
         at java.lang.reflect.Method.invoke(Native Method)
         at weblogic.ejb20.manager.StatefulSessionManager.create(StatefulSessionManager.java:747)
         at weblogic.ejb20.manager.StatefulSessionManager.remoteCreate(StatefulSessionManager.java:799)
         at weblogic.ejb20.internal.StatefulEJBHome.create(StatefulEJBHome.java:159)
         at com.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_HomeImpl.create(HouseManagerBean_wnwfw3_HomeImpl.java:77)
         at com.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_HomeImpl_WLSkel.invoke(Unknown
    Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
         at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:785)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    ; nested exception is: javax.transaction.HeuristicMixedException: (weblogic.jdbc.jts.Connection,
    HeuristicHazard, (javax.transaction.xa.XAException: Can't call commit when autocommit=true))
    Is this because MySQL is non-transactional? Should I change to transactional tables
    with MySQL, tweak driver somehow to be "autocommit=false" or what?
    Any help is greatly appreciated.

    MySQL comes in two flavors - MySQL and MySQL-MAX. The second
    one supports TXs, the first one doesn't. That could be the case, too.
    Slava
    "Joseph Weinstein" <[email protected]> wrote in message
    news:[email protected]...
    Hi. It sounds like the DBMS doesn't handle standard transactions, and the
    driver lies. We'll set autoCommit(false) to start an EJB transaction. It
    sounds like the driver accepts the call and blithely ignores it. Later,
    when we prepared to call commit, the driver lets us know that theconnection
    is autoCommit(true) meaning there's nothing to commit.
    "Jari Länsiö" wrote:
    Hello,
    I'm trying to use WebLogic 7.0 with MySQL 3.23.49 and MySQL Connector/J
    JDBC driver
    2.0.14. Everything has been working just fine but now I keep gettingexception:
    >>
    java.rmi.RemoteException: EJB Exception:; nested exception is:
    javax.ejb.EJBException: EJB Exception: :javax.transaction.HeuristicMixedException:
    (weblogic.jdbc.jts.Connection, HeuristicHazard,(javax.transaction.xa.XAException:
    Can't call commit when autocommit=true))
    atweblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTra
    nsactionImpl.java:258)
    atweblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransaction
    Impl.java:208)
    atweblogic.ejb20.internal.BaseEJBLocalHome.postHomeInvoke(BaseEJBLocalHome.jav
    a:314)
    atweblogic.ejb20.internal.EntityEJBLocalHome.findByPrimaryKey(EntityEJBLocalHo
    me.java:289)
    atcom.nokia.m2m.demo.housemanagement.ejb.HouseBean_15mjuo_LocalHomeImpl.findBy
    PrimaryKey(HouseBean_15mjuo_LocalHomeImpl.java:137)
    atcom.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean.ejbCreate(HouseManag
    erBean.java:326)
    atcom.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_Impl.ejbCreat
    e(HouseManagerBean_wnwfw3_Impl.java:117)
    at java.lang.reflect.Method.invoke(Native Method)
    atweblogic.ejb20.manager.StatefulSessionManager.create(StatefulSessionManager.
    java:747)
    atweblogic.ejb20.manager.StatefulSessionManager.remoteCreate(StatefulSessionMa
    nager.java:799)
    atweblogic.ejb20.internal.StatefulEJBHome.create(StatefulEJBHome.java:159)
    atcom.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_HomeImpl.crea
    te(HouseManagerBean_wnwfw3_HomeImpl.java:77)
    atcom.nokia.m2m.demo.housemanagement.ejb.HouseManagerBean_wnwfw3_HomeImpl_WLSk
    el.invoke(Unknown
    Source)
    atweblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    atweblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java
    :114)
    atweblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    atweblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:785)
    atweblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
    atweblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
    0)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    ; nested exception is: javax.transaction.HeuristicMixedException:(weblogic.jdbc.jts.Connection,
    HeuristicHazard, (javax.transaction.xa.XAException: Can't call commitwhen autocommit=true))
    >>
    Is this because MySQL is non-transactional? Should I change totransactional tables
    with MySQL, tweak driver somehow to be "autocommit=false" or what?
    Any help is greatly appreciated.

Maybe you are looking for

  • Stock validation of main position in Free Goods Determination

    Good afternoon, We are using Free Goods determination, but we are having a problem when there is no available stock in the main position, SAP is determining quantities of Free Goods; what we want is customize in SPRO to obligate that only we can gene

  • Transfer of G/L account

    Hi Gurus, Can anybody tell me how to transfer one g/l to another g/l a/c Ex:For example i have 2 salaries accounts salaries1 and salaries2 accounts how can i transfer entire transactions of salaries1 to salaries2 account. sd/- Sreenivasulu.P

  • Can you change you iPod Name?

    I need the chnage the name of my iPod, is that possible? If so, how?

  • Can Captivate be set to advance when only a certain key is pressed

    I am doing software training simulation.  I am trying to teach the user how to do a set of tasks.  In the software you must press certain key to accomplish certain steps so  I want to set captivate to advance to the next slide only when the correct k

  • I can't modify my desktop

    Yesterday I tried to open some files from folders located on my desktop. I got a message saying that I could not open the files because they were in the Trash. So I opened my trash and saw a folder labeled "Desktop" in there. I don't know how the "De