Show Table of Contents
2.2. Connecting to the Red Hat Virtualization Manager in Version 4
In V4 of the Java software development kit, the
Connection class is the main class you use to connect to and manipulate objects in a Red Hat Virtualization environment. To declare an instance of this class, you must declare an instance of the ConnectionBuilder class, pass the required arguments to this instance using builder methods, then call the build method on the instance. The build method returns an instance of the Connection class that you can then assign to a variable and use to perform subsequent actions.
The following is an example of a simple Java SE program that creates a connection with a Red Hat Virtualization environment using version 4 of the software development kit:
Example 2.2. Connecting to the Red Hat Virtualization Manager
package rhevm;
import org.ovirt.engine.sdk4.Connection;
import org.ovirt.engine.sdk4.ConnectionBuilder;
public class rhevm {
public static void main(String[] args) {
ConnectionBuilder myBuilder = ConnectionBuilder.connection()
.url("https://rhevm.example.com/ovirt-engine/api")
.user("admin@internal")
.password("p@ssw0rd")
.trustStoreFile("/home/username/server.truststore")
.trustStorePassword("p@ssw0rd");
try (Connection conn = myBuilder.build()) {
// Requests
} catch (Exception e) {
// Error handling
}
}
}
This example creates a connection using basic authentication, but other methods are also available. For a list of the key arguments that can be passed to instances of the
ConnectionBuilder class, see Appendix B, ConnectionBuilder Methods.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.