File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
includes/fundamentals/code-snippets Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,9 @@ and commit a multi-document insert operation through the following steps:
97
97
the transaction. If any operation results in errors, ``withTransaction()`` handles canceling
98
98
the transaction.
99
99
100
- .. literalinclude:: /includes/fundamentals/code-snippets/Transactions .java
100
+ .. literalinclude:: /includes/fundamentals/code-snippets/Transaction .java
101
101
:language: java
102
+ :start-after: end imports
102
103
103
104
If you require more control over your transactions, you can use the ``startTransaction()``
104
105
method. This method allows you to explicitly commit or abort the transaction and manually
@@ -130,4 +131,4 @@ guide, see the following API Documentation:
130
131
- `abortTransaction <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/ClientSession.html#abortTransaction()>`_
131
132
- `withTransaction <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/ClientSession.html#withTransaction(com.mongodb.client.TransactionBody)>`_
132
133
- `TransactionOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/TransactionOptions.html>`_
133
- -
134
+
Original file line number Diff line number Diff line change 1
- import com .mongodb .*;
1
+ package fundamentals ;
2
+
3
+ // begin imports
2
4
import com .mongodb .client .*;
5
+ import com .mongodb .client .MongoClient ;
3
6
import com .mongodb .client .model .WriteConcern ;
4
7
import org .bson .Document ;
5
8
6
9
import java .util .Arrays ;
10
+ // end imports
7
11
8
12
public class Transaction {
9
13
public static void main (String [] args ) {
You can’t perform that action at this time.
0 commit comments