Transactions, disabling auto-commit
Hello,
Is it possible to disable autocommit in HTML DB? If not, how would it handle the following situation:
insert A -- succeeded
insert B -- failed
Would insert A be committed or would the exception thrown cause a rollback to a point before A?
Pavel
Pavel,
Sergio is correct. The commit of session state and other information in HTML DB, at a minimum, happens at the end of every page view. There is no way for you to disable this. A raised exception will not do an implicit rollback of your transaction. You would need to rollback yourself.
Keep in mind, though, if you rollback the transaction, anything else not committed in this transaction (let's say modifications in a prior page process but in the same page view) will also be rolled back.
Joel
Similar Messages
-
I have developed a web serice using JDeveloper, the Web service is rapped on ORACLE DB packages.
so I use the JDeveloper wizard to create the Web service using the DB connection.
and I deployed it using ORACLE application server, when I tested the web service using Internet explorer, I found that all transactions are committed though there is no commit code in the DB packages.
How can I make the webservice disable the auto commit, Actulally I don't know if this commit is made by the application server or by the JAVA application or by Internet Explorer.Thank you for your answer. My problem is:
I have an pl/sql package building a web page using mod pl/sql and Apache.
What happened is that I don't need to explicit commit for all the DB operations (insert/update): it is automatic! If I want to handle the commit/rollback what I have to do inside my code?
Best Regards,
Lorenzo.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Ganesh Raja ([email protected]):
Hi,
There is nothing as Auto Comit in PL/SQL it is a Concept of u'r SQLPLUS.
Wht u should do is say set Autocommit off
If u need any more help get back..
Regards,
Ganesh R<HR></BLOCKQUOTE>
null -
Hello,
is there a way to disable the auto commit in plsql code? In my knowledge it is setted to true using plsql code...
Thank you.
Lorenzo.Thank you for your answer. My problem is:
I have an pl/sql package building a web page using mod pl/sql and Apache.
What happened is that I don't need to explicit commit for all the DB operations (insert/update): it is automatic! If I want to handle the commit/rollback what I have to do inside my code?
Best Regards,
Lorenzo.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Ganesh Raja ([email protected]):
Hi,
There is nothing as Auto Comit in PL/SQL it is a Concept of u'r SQLPLUS.
Wht u should do is say set Autocommit off
If u need any more help get back..
Regards,
Ganesh R<HR></BLOCKQUOTE>
null -
Hi All,
OracleXMLSave class in the Oracle XDK is being used to load XML data into an 8170 database. The Java code is running in IBM WebSphere with container-managed transactions. When JTA is enabled with the Merant JDBC driver for Oracle, we get the following error when the XML is loaded:
oracle.xml.sql.OracleXMLSQLException: Cannot enable auto commit within JTS
transaction
at java.lang.Throwable.fillInStackTrace(Native Method)
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2213)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(Compiled Code)
This suggests the OracleXMLSave class is not aware of the fact that it is now operating in a JTS transaction where control is managed elsewhere. i.e. should also not attempt to commit or rollback, as this is the responsibility of the container.
Is there a property which needs to set to prevent the above or does the XDK not work with J2EE (JTS) transactions?.
If you have any useful comments, let me know. Testing the above presents me with a number of problems so if this is easily explained , let me know.
Thanks,
MalcolmClearly , there does seem to be something a bit odd with the above stack.
<Bug:1917808> mentions OracleXMLSave in context of plsql equivalent : dbms_xmlsave . i.e dbms_xmlsave is a wrapper around OracleXMLSave class.
disabling autocommit on connection as follows should help:
conn = DriverManager.getConnection("connect string","scott","tiger");
conn.setAutoCommit(false);
to disble auto commit and see if this has an effect.
This issue might be <Bug:1497506>. If disabling autocommit does not work then it appears that it could be this issue .
Malcolm
Hi All,
OracleXMLSave class in the Oracle XDK is being used to load XML data into an 8170 database. The Java code is running in IBM WebSphere with container-managed transactions. When JTA is enabled with the Merant JDBC driver for Oracle, we get the following error when the XML is loaded:
oracle.xml.sql.OracleXMLSQLException: Cannot enable auto commit within JTS
transaction
at java.lang.Throwable.fillInStackTrace(Native Method)
at oracle.xml.sql.dml.OracleXMLSave.saveXML(OracleXMLSave.java:2213)
at oracle.xml.sql.dml.OracleXMLSave.insertXML(Compiled Code)
This suggests the OracleXMLSave class is not aware of the fact that it is now operating in a JTS transaction where control is managed elsewhere. i.e. should also not attempt to commit or rollback, as this is the responsibility of the container.
Is there a property which needs to set to prevent the above or does the XDK not work with J2EE (JTS) transactions?.
If you have any useful comments, let me know. Testing the above presents me with a number of problems so if this is easily explained , let me know.
Thanks,
Malcolm -
Could not turn on auto-commit in an active global transaction
Why and when does toplink throw this exception
09/09/28 17:50:58 Caused by: java.sql.SQLException: could not turn on auto-commit in an active global transaction
09/09/28 17:50:58 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
09/09/28 17:50:58 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
09/09/28 17:50:58 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
09/09/28 17:50:58 at oracle.jdbc.driver.PhysicalConnection.disallowGlobalTxnMode(PhysicalConnection.java:4045)
09/09/28 17:50:58 at oracle.jdbc.driver.PhysicalConnection.setAutoCommit(PhysicalConnection.java:1343)
09/09/28 17:50:58 at oracle.jdbc.OracleConnectionWrapper.setAutoCommit(OracleConnectionWrapper.java:107)
09/09/28 17:50:58 at oracle.oc4j.sql.spi.ManagedConnectionImpl.setAutoCommit(ManagedConnectionImpl.java:572)
09/09/28 17:50:58 at oracle.oc4j.sql.spi.ManagedConnectionImpl.initForUse(ManagedConnectionImpl.java:167)
09/09/28 17:50:58 at oracle.oc4j.sql.spi.ManagedConnectionImpl.<init>(ManagedConnectionImpl.java:106)
09/09/28 17:50:58 at oracle.oc4j.sql.spi.ManagedConnectionFactoryImpl.createManagedConnection(ManagedConnectionFactoryImpl.java:171)
09/09/28 17:50:58 at com.evermind.server.connector.ApplicationConnectionManager.createManagedConnection(ApplicationConnectionManager.java:1398)
09/09/28 17:50:58 at oracle.j2ee.connector.ConnectionPoolImpl.createManagedConnectionFromFactory(ConnectionPoolImpl.java:327)
09/09/28 17:50:58 at oracle.j2ee.connector.ConnectionPoolImpl.access$800(ConnectionPoolImpl.java:98)
09/09/28 17:50:58 at oracle.j2ee.connector.ConnectionPoolImpl$NonePoolingScheme.getManagedConnection(ConnectionPoolImpl.java:1211)
09/09/28 17:50:58 at oracle.j2ee.connector.ConnectionPoolImpl.getManagedConnection(ConnectionPoolImpl.java:785)
09/09/28 17:50:58 at oracle.oc4j.sql.ConnectionPoolImpl.getManagedConnection(ConnectionPoolImpl.java:45)
09/09/28 17:50:58 at com.evermind.server.connector.ApplicationConnectionManager.getConnectionFromPool(ApplicationConnectionManager.java:1596)
09/09/28 17:50:58 at com.evermind.server.connector.ApplicationConnectionManager.acquireConnectionContext(ApplicationConnectionManager.java:1541)
09/09/28 17:50:58 at com.evermind.server.connector.ApplicationConnectionManager.allocateConnection(ApplicationConnectionManager.java:1486)
09/09/28 17:50:58 at oracle.j2ee.connector.OracleConnectionManager.unprivileged_allocateConnection(OracleConnectionManager.java:238)
09/09/28 17:50:58 at oracle.j2ee.connector.OracleConnectionManager.allocateConnection(OracleConnectionManager.java:192)
09/09/28 17:50:58 at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:272)
09/09/28 17:50:58 at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:200)
09/09/28 17:50:58 at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:142)
09/09/28 17:50:58 at oracle.oc4j.sql.ManagedDataSource.getConnection(ManagedDataSource.java:127)
09/09/28 17:50:58 at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:145)
Thanks,
NDHello,
As you can tell from the stack trace, TopLink is not throwing the exception, the connection is when TopLink is attempting to get a connection from the datasource. getConnection should not be throwing this exception, so it is likely a datasource configuration issue or a problem in the driver you are using. How is the datasource configured, what is the version of Oc4J and the driver you are using, and can you try using a different driver version?
Best Regards,
Chris -
Hi,
I am using BC4J with Struts to develop a web application. I want to auto commit whenever user creates new or update a record. I am doing following in XXXEditAction.java
BC4JContext context = BC4JContext.getContext(request);
context.getApplicationModule().getTransaction().commit();
It works sometime and doesn't sometimes and locks record. So Could anyone please help me in solving this.
Thanks,
KavithaHello,
Just a suggestion.�.try to catch �RowInconsistentException� exception and rollback the transaction.
try {
context.getApplicationModule().getTransaction().commit();
} catch (RowInconsistentException e) {
context.getApplicationModule().getTransaction().rollback();
System.out.println("Some Exception in Commit : " +
e.getMessage());
Regards
Sanjay. -
Auto-commit occurs even when preference disabled
In the menu under TOOLS > PREFERENCES > Database Connections, there is an option that says "Autocommit in SQL Worksheet". It seems that sometimes DML statements are committed immediately even if this option is turned off.
I am experiencing this problem on SQL Developer Version 1.0.0.15.57 running on Windows 2000 (5.00.2195 Service Pack 4). Not sure if it matters, but the database is 10.2.0.1 Enterprise Edition running on LINUX RHAS 3.0 Update 4.
Is this a known bug? Is it fixed in future releases?
Thanks,
BurtAuto-commit preference for worksheet, if turned on, would issue commit immediately after you run DML from worksheet.
If it's turned off and you still see changes data being commit, I think it's possible only in another scenario where you have Auto-commit preference for worksheet turned off, issue DML from worksheet and subsequently do a commit in data grid.
Commit button is present in both data grid and in sql worksheet, and sql developer uses only one connection/session. So, a commit in grid is going to commit your worksheet issued DMLs.
Grid data is not commited that way unless you have grid's auto-commit preference on (that preference is in ObjectViewer preference node).
HTH
-Raghu -
Hello Sir,
how can i set auto commit on/off using apex in application builder, auto commit is there in sql command but not in application builder,it is possible to set auto commit using coding in apex processes or PL/SQL Block.
please help me.
Thanks in Advance,
Regards,
Jack R.Hi Varad,
Thanks for your quick reply,
I want to manually handle commit and rollback on DML.
can you explain about a stateless transaction model and span requests in apex?
Thanks & Regards,
Jack R. -
Cannot enable auto commit within JTS using websphere
i suddenly encountered some exceptions like this yet the process seems to be ok. i am pretty new to websphere, help please:
java.lang.IllegalStateException: Cannot enable auto commit within JTS transaction
at com.ibm.ejs.cm.pool.ConnectO.setAutoCommit(ConnectO.java:2085)
at com.ibm.ejs.cm.proxy.ConnectionProxy.setAutoCommit(ConnectionProxy.java:594)I'm setting autoCommit to false in some of my code and it works. Here is the example:
//This code works for the Oracle Thin Driver
conn.setAutoCommit(false); // <- required!
// initialize LOB reference
GDate curDate = new GDate();
ps = conn.prepareStatement("insert into Calculated_Rate_Import values (empty_clob(), ?)");
//conn.createStatement().executeUpdate("insert into Calculated_Rate_Import values (empty_clob(), TO_DATE('" + GDate.getSafeSqlDate(curDate) + "'))");
ps.setTimestamp(1, GDate.getSafeTimestamp(curDate));
ps.executeUpdate();
ps = conn.prepareStatement("select Calculated_Rate_Import from Calculated_Rate_Import where Import_Date = ? for update");
ps.setTimestamp(1, GDate.getSafeTimestamp(curDate));
results = ps.executeQuery();
results.next();
// get lob reference from write lock
//oracle.sql.CLOB clob = ((oracle.jdbc.driver.OracleResultSet)results).getCLOB(1);
oracle.sql.CLOB clob = (oracle.sql.CLOB)results.getClob("Calculated_Rate_Import");
// create statement for update
ps = conn.prepareStatement("update Calculated_Rate_Import set Calculated_Rate_Import = ? where Import_Date = ?");
// stream data into lob
java.io.OutputStream os = ((oracle.sql.CLOB)clob).getAsciiOutputStream();
try{
os.write(fileContents.getBytes());
os.close();
}catch(IOException e){
e.printStackTrace();
// execute update
//((oracle.jdbc.driver.OraclePreparedStatement)ps3).setCLOB(1, clob);
ps.setClob(1, clob);
ps.setTimestamp(2, GDate.getSafeTimestamp(curDate));
ps.executeUpdate();
// close lock
results.close();
conn.commit();
//finished inserting CLOB
//set the auto commit back to true, required!
conn.setAutoCommit(true); -
Auto-Commit and Pooled JDBC Connections
Forum Members,
If I am using Oracle Pooled JDBC Connections in the OC4J container is auto-commit set to "true" by default?
If I set auto-commit to "false" and then close the logical connection, when that connection is handed out again on a later call to getConnection(), is auto-commit automatically set back to "true"?
Thanks,
RichardRichard,
Pardon me if I am stating the obvious, but you could test that in your code by invoking the getAutoCommit() method in interface java.sql.Connection.
My experience (with OC4J stand-alone versions up to -- and including -- 10.1.2) is that the behaviour depends on which data source you have configured. For example, if you have defined an "ejb-location" attribute in your "data-sources.xml" file, and you use that as your JNDI lookup for your data source, then OC4J handles transactions and you shouldn't deal with "auto-commit" at all. See the following post for more details:
Re: OC4J 10.1.3 Preview 4 - Global transaction active
But if you have defined a "location" attribute and use that, then you do need to handle transactions explicitly.
Hope this helps.
Good Luck,
Avi. -
Hello All,
Is this possible to set Auto Commit on/off
between DM statements in a PL/SQL block
Please suggest me.
Thanks in advance.No, you will have to explicitly issue a COMMIT or ROLLBACK when it makes sense to do it.
The autocommit feature of SQL*Plus (a client application) is not available inside PL/SQL.
However, an entire PL/SQL block when run from SQL*Plus would be considered as one statement (unit) and autocomit (if enabled) will commit all DML statements performed inside the PL/SQL block (and any blocks called from it).
Generally, its not a good idea to use this autocommit feature (even if available) since you lose all the control over your transactions. Your transaction never spans one single statement at a time. -
Auto commit in BAPI_MATERIAL_SAVEDATA
hi
i want to know whether there is an auto commit in this method BAPI_MATERIAL_SAVEDATA or do we need to explicitly commit
Correct answer will be suitably rewardedHi Baldeep,
I dont think there is any parameter in this method which will let u know whether this method does an auto commit or not.
I normally execute the BAPI with the basic required data and check whether it is updating the database tables, and if the tables get updated then there is no need to explicitly commit or rollback, but if it does not update the database tables then I do an explicit commit.
I guess all this has got to do with the difference in creating master data and the transaction data. When ever u are using a bapi to create the master data u dont have to do an explicit commit. But when ur creating a transaction data in the database u have to do an explicit commit.
Thanks
Elan -
As we all know that the database file is committed when the cache is filled, i.e auto commit happens.Is there any way to disable this auto commit feature apart from increasing the cache size
Regards
NandishHi,
I would like to thank you on behalf of our team for your valuable suggestions.
1)With the TDS approach, I will start buiding my application on TDS and test its performance including mem_trickle
2)Regarding the crash during the sync, yes you are correct and we are in trouble in case of crash at this point.
3)This is the readings of db_stat during the drip in performance on a load test carried out using HASH access method and Cache size of 500MB
500MB Total cache size
5 Number of caches
100MB Pool individual cache size
0 Maximum memory-mapped file size
0 Maximum open file descriptors
0 Maximum sequential buffer writes
0 Sleep after writing maximum sequential buffers
0 Requested pages mapped into the process' address space
6848119 Requested pages found in the cache (92%)
581096 Requested pages not found in the cache
122467 Pages created in the cache
532998 Pages read into the cache
619356 Pages written from the cache to the backing file
26768 Clean pages forced from the cache
565731 Dirty pages forced from the cache
0 Dirty pages written by trickle-sync thread
62745 Current total page count
61790 Current clean page count
955 Current dirty page count
81905 Number of hash buckets used for page location
8075897 Total number of times hash chains searched for a page
36 The longest hash chain searched for a page
11M Total number of hash chain entries checked for page (11001641)
2208 The number of hash bucket locks that required waiting (0%)
4 The maximum number of times any hash bucket lock was waited for (0%)
1996 The number of region locks that required waiting (0%)
0 The number of buffers frozen
0 The number of buffers thawed
0 The number of frozen buffers freed
655397 The number of page allocations
1249322 The number of hash buckets examined during allocations
9 The maximum number of hash buckets examined for an allocation
592572 The number of pages examined during allocations
2 The max number of pages examined for an allocation
11 Threads waited on page I/O
Pool File: /CDR/vol1/1/FragmentFile7.db
8192 Page size
0 Requested pages mapped into the process' address space
972938 Requested pages found in the cache (92%)
83856 Requested pages not found in the cache
17854 Pages created in the cache
76608 Pages read into the cache
89083 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile6.db
8192 Page size
0 Requested pages mapped into the process' address space
986504 Requested pages found in the cache (92%)
82072 Requested pages not found in the cache
17725 Pages created in the cache
74929 Pages read into the cache
87985 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile2.db
8192 Page size
0 Requested pages mapped into the process' address space
961590 Requested pages found in the cache (92%)
83302 Requested pages not found in the cache
17541 Pages created in the cache
76242 Pages read into the cache
88397 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile1.db
8192 Page size
0 Requested pages mapped into the process' address space
988376 Requested pages found in the cache (92%)
83576 Requested pages not found in the cache
17080 Pages created in the cache
77228 Pages read into the cache
89664 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile4.db
8192 Page size
0 Requested pages mapped into the process' address space
978263 Requested pages found in the cache (92%)
82870 Requested pages not found in the cache
17557 Pages created in the cache
75985 Pages read into the cache
88119 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile3.db
8192 Page size
0 Requested pages mapped into the process' address space
985921 Requested pages found in the cache (92%)
82795 Requested pages not found in the cache
17151 Pages created in the cache
76320 Pages read into the cache
88019 Pages written from the cache to the backing file
Pool File: /CDR/vol1/1/FragmentFile5.db
8192 Page size
0 Requested pages mapped into the process' address space
974527 Requested pages found in the cache (92%)
82625 Requested pages not found in the cache
17559 Pages created in the cache
75686 Pages read into the cache
88089 Pages written from the cache to the backing file
Page size is 8K(OS default on Solaris 9)
File system info
nsect=720,ntrack=8,bsize=8192,fragsize=1024,cgsize=8,free=1,rps=167,nbpi=1026,opt=t,apc=0,gap=0,nrpos=8,maxcontig=128 /dev/dsk/c2t5d0s0 286732800
Key : Integer
Data : An object of size 200 bytes
Regards
Nandish
Message was edited by:
user590453 -
Medrec pointbase orace RDBMS migration (Cannot set auto-commit mode)
For proof-of-concept purposes, I'm trying to install the MEDREC application on an Oracle database. I've migrated the schema using the demo.ddl found on the base install image. However, when I update the JDBC connect string to point to the oracle rdbms, I rec'v the message below. Has anyone discovered a workaround?
After the jdbc connect string is updated to point to Oracle, I see the app server connected successfully to the database.
javax.ejb.EJBTransactionRolledbackException: EJB Exception: ; nested exception is: <openjpa-1.1.0-r422266:657916 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Cannot set auto-commit mode when using distributed transactions
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:794)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:486)
at weblogic.ejb.container.internal.BaseLocalObject.postInvokeTxRetry(BaseLocalObject.java:424)For proof-of-concept purposes, I'm trying to install the MEDREC application on an Oracle database. I've migrated the schema using the demo.ddl found on the base install image. However, when I update the JDBC connect string to point to the oracle rdbms, I rec'v the message below. Has anyone discovered a workaround?
After the jdbc connect string is updated to point to Oracle, I see the app server connected successfully to the database.
javax.ejb.EJBTransactionRolledbackException: EJB Exception: ; nested exception is: <openjpa-1.1.0-r422266:657916 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Cannot set auto-commit mode when using distributed transactions
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:794)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:486)
at weblogic.ejb.container.internal.BaseLocalObject.postInvokeTxRetry(BaseLocalObject.java:424) -
Does anyone know How to Disable "Auto Align" in [System Preferences] -> [Display] -> [Arrangement]?
It always want to align the two screens from the top when they are lined up close together and I need them to be aligned from the bottom. Since the resolution heights are so close together (1080 & 1050) it does not allow one to align side by side from the bottom as it prioritizes top alignment.
I guess I'm looking for a script to disable this feature.Anyone got any ideas?
Maybe you are looking for
-
Separate Work email from Personal email?
Problem: I want to keep my .mac email account on my main personal MacBookPro when I open the email program Mail in my dock. I work at a company on a mac too and I use Sync to sync up browser bookmarks and calendar (I do not have Mail selected in the
-
Documents service disabled for Oracle Spaces. How to I enable it. I previously had no problem with this.
-
"Windows encountered an unexpected error" while configuring devices
I've run into an interesting issue after upgrading from SP1 to R2. Two of my images are failing while Windows configures devices at 72%. The models are Lenovo x131 and x140 which were previously working before the upgrade. All other images are workin
-
How to talk to a real person?
Hello, I've looked on the contact us page a couple times, everything just redirects to more pages that do not seem to help. How do I call to talk to someone regarding billing? I recently merged my wife's plan with my previous family plan and was assu
-
Adding EXTRA metadata into description field Pshop Bridge
Hi I have got lots of pictures in photoshop which are all captioned neatly. However one of the agencies I supply to, requires me to add my credit details into the description field after the description. Is there anyway I can do this as a batch. Many