Restriction: This topic applies to Windows environments only.
You must load the Direct Flight driver before you can connect to an XDB Server. The simplest way to load the driver is to use the following code:
Class.forName ("mf.jdbc.DFDriver");
Where DFDriver is the name of the Micro Focus Direct Flight driver.
This creates an instance of the mf.jdbc.DFDriver class which represents the Direct Flight driver and registers the driver with your Java development environment Driver Manager.
The following code examples demonstrate two other methods for loading the driver:
In this example, the driver is loaded before calling the DriverManager.getConnection method:
Connection login(String sUser, String sPassword)
throws SQLException {
String sURL = “jdbc.mf://myhost”;
Driver driver = new mf.jdbc.DFDriver();
return DriverManager.getConnection(sURL, sUser, sPassword);
}
In this example, mf.jdbc.DFDriver is instantiated within the static code of the class that connects to the XDB Server:
Class MyClass {
static {
try {
Driver driver = new mf.jdbc.DFDriver();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}