From 4cf75860e1778f8bd3d8b10dc562b20e5871619a Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 9 Jun 2023 06:35:34 +0300 Subject: [PATCH] #221: doc --- src/main/java/com/jcabi/jdbc/JdbcSession.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/jcabi/jdbc/JdbcSession.java b/src/main/java/com/jcabi/jdbc/JdbcSession.java index 2fbeee9..b17a59b 100644 --- a/src/main/java/com/jcabi/jdbc/JdbcSession.java +++ b/src/main/java/com/jcabi/jdbc/JdbcSession.java @@ -101,13 +101,14 @@ * .sql("SHUTDOWN COMPACT") * .execute(); * - * IMPORTANT: + *

IMPORTANT:

+ * *

If you rely on one specific {@link Connection} instance, be careful if * you are using it in more places, especially if more references of this class * use it - one of those references might close the connection if you forget - * to call {@link #autocommit(false)} - *

- * E.g. + * to call {@link JdbcSession#autocommit(boolean)} with {@code false} as an argument, + * for example:

+ * *
  * Connection connection = [...];
  * DataSource ds = new StaticSource(connection);
@@ -117,11 +118,12 @@
  * new JdbcSession(ds)
  *  .sql("SQL STATEMENT 2")
  *  .execute();
+ *

The above example will fail because the first JdbcSession closes * the connection, and the next one tries to work with it closed. In order to * not have this failure, the first session has to call - * {@link #autocommit(false)}, like this: - *

+ * {@link #autocommit(boolean)} with {@code false} as an argument, like this:

+ * *
  * Connection connection = [...];
  * DataSource ds = new StaticSource(connection);