Transaction
- [Specification] Large object operations do not support transactions.
Large object operations include CREATE/DELETE DATABASE, ANALYZE, and VACUUM.
- [Rule] When accessing the database through the JDBC client, disable the autocommit parameter and explicitly execute the transaction COMMIT.
- On the one hand, enabling the autocommit parameter will cause some parameters (such as fetchsize) to become invalid.
- On the other hand, the service should clarify the service logic and reduce the dependence on the database.
- [Rule] Do not combine multiple SQL statements into one statement when accessing the database through JDBC.
If multiple statements are combined into one, as long as one of them fails to be executed, the whole statement fails and a failure message is returned. This is inconvenient for fault locating. You are advised to split the statement.
Example:- The following statement does not meet specifications:
Connection conn = .... try { Statement stmt = null; try { stmt = conn.createStatement(); stmt.executeUpdate("CREATE TABLE t1 (a int); DROP TABLE t1"); } finally { stmt.close(); } conn.commit(); } catch(Exception e) { conn.rollback(); } finally { conn.close(); }
- You are advised to split the statement into two statements and send them separately:
Connection conn = .... try { Statement stmt = null; try { stmt = conn.createStatement(); stmt.executeUpdate("CREATE TABLE t1 (a int)"); stmt.executeUpdate("DROP TABLE t1"); } finally { stmt.close(); } conn.commit(); } catch(Exception e) { conn.rollback(); } finally { conn.close(); }
- The following statement does not meet specifications:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot