I have never used mysql for several years... Mysql is used for a small task today. A very simple problem. After several hours, it seems that ignorance is terrible .. Go to the topic. The problem is simple. JDBC connects to mysl to get connnection and then conn. setAutoCommit (false); the point is to insert a record, inset1 ...... then perform some logic processing to update another data update2... Finally, conn. commit (); of course, there is conn. rollback () in catche (). DEBUG finds that the database has a value after insert1 is executed .. I thought it was an isolation-level problem and did not care about it. Then proceed to the logic processing. The conn. reollback () exception occurs .. The inserted data is not rolled back. The code is checked N times without any problems. I have no choice but to ask du Niang, Gu Ye... This period of time is suffering ~~~~ Www.2cto.com is still fruitful. I found an article about the mysql table storage engine. Show create table name;
We can see that ENGINE = MyISAMMyISAM refers to the default storage ENGINE of Mysql. When creating a new table without specifying the storage ENGINE for the new table, Myisam is used by default. MyISAM manages non-transaction tables. It provides high-speed storage and retrieval, and full-text search capabilities. Since there are non-transaction tables, there should be tables that support transactions. Indeed, du Niang told me that the InnoDBInnoDB storage engine provides transaction security with the ability to commit, roll back, and crash recovery. However, compared with the storage engine of Myisam, InnoDB writes less efficiently and occupies more disk space to retain data and indexes. Let's change it .. Alter table name engine = InnoDB; then let's take a look.
Changed to InnoDB .. Run the program again .. That's right. Roll back... Very small problem .... However, if you do not know about Mysql, it is also a headache .. After several hours... Ignorance is a sad reminder ....
Author: Beijing-Wang Zhiwei