System.out.println("Writing values with the class `Transaction`:");
System.out.print(" Initialising Transaction object... ");
try {
final Transaction transaction = new Transaction();
System.out.println("done");
System.out.print(" Starting transaction... ");
System.out.println("done");
System.out
.println(" `writeObject(OtpErlangString, OtpErlangObject)`...");
for (int i = 0; i < otpKeys.arity(); ++i) {
final OtpErlangString otpKey = (OtpErlangString) otpKeys.elementAt(i);
final OtpErlangString otpValue = (OtpErlangString) otpValues
.elementAt(i);
try {
transaction.write(otpKey, otpValue);
System.out.println(" write(" + otpKey.stringValue()
+ ", " + otpValue.stringValue() + ") succeeded");
} catch (final ConnectionException e) {
System.out.println(" write(" + otpKey.stringValue()
+ ", " + otpValue.stringValue() + ") failed: "
+ e.getMessage());
} catch (final TimeoutException e) {
System.out.println(" write(" + otpKey.stringValue()
+ ", " + otpValue.stringValue()
+ ") failed with timeout: " + e.getMessage());
} catch (final UnknownException e) {
System.out.println(" write(" + otpKey.stringValue()
+ ", " + otpValue.stringValue()
+ ") failed with unknown: " + e.getMessage());
}
}
System.out.println(" `write(String, String)`...");
for (int i = 0; i < keys.length; ++i) {
final String key = keys[i];
final String value = values[i];
try {
transaction.write(key, value);
System.out.println(" write(" + key + ", " + value
+ ") succeeded");
} catch (final ConnectionException e) {
System.out.println(" write(" + key + ", " + value
+ ") failed: " + e.getMessage());
} catch (final TimeoutException e) {
System.out.println(" write(" + key + ", " + value
+ ") failed with timeout: " + e.getMessage());
} catch (final UnknownException e) {
System.out.println(" write(" + key + ", " + value
+ ") failed with unknown: " + e.getMessage());
}
}
System.out.print(" Committing transaction... ");
transaction.commit();
System.out.println("done");
} catch (final ConnectionException e) {
System.out.println("failed: " + e.getMessage());
return;
} catch (final TimeoutException e) {