Skip to content

Commit

Permalink
#221: doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jun 9, 2023
1 parent 05d55bd commit 4cf7586
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/com/jcabi/jdbc/JdbcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@
* .sql("SHUTDOWN COMPACT")
* .execute();</pre>
*
* <b>IMPORTANT:</b>
* <p><b>IMPORTANT:</b></p>
*
* <p>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)}
* </p>
* <b>E.g.</b>
* to call {@link JdbcSession#autocommit(boolean)} with {@code false} as an argument,
* for example:</p>
*
* <pre>
* Connection connection = [...];
* DataSource ds = new StaticSource(connection);
Expand All @@ -117,11 +118,12 @@
* new JdbcSession(ds)
* .sql("SQL STATEMENT 2")
* .execute();</pre>
* <p>The above example will <b>fail</b> 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:
* </p>
* {@link #autocommit(boolean)} with {@code false} as an argument, like this:</p>
*
* <pre>
* Connection connection = [...];
* DataSource ds = new StaticSource(connection);
Expand Down

0 comments on commit 4cf7586

Please sign in to comment.