Java Reference
In-Depth Information
21.
"JDMException Occured: "
22.
lException.getMessage());
23.
lException.printStackTrace();
24.
} catch (ClassNotFoundException lException) {
25.
JOptionPane.showMessageDialog(this,
26.
"The specified Connection factory was not found. "
27.
"Verify the class name and the classpath.");
28.
} catch (Exception lExce) {
29.
lMsg "Error occured while collecting vendor information.";
30.
} finally {
31.
mMetaInfo.setText(lMsg);
32.
}
33.}
This code shows how to get a connection object. This connection
instance will be used throughout each of the GUI examples. The
code of getJDMConnection is explained later, but assuming that the
connection is established, the code shows how to retrieve vendor
information between lines 9 and 12.
If a JDM exception occurs at that point, it will be mainly a badly
formed URI. The only thing the designer can do in this case is to
display the vendor message obtained from lException.getMes-
sage(). A more carefully designed application should use the ven-
dor documentation to ensure that the URI is properly formatted.
The ClassNotFoundException will be raised if the user provides a
class name that does not correspond to any valid JDM connection
factory class.
The code also shows how to retrieve the maximum length of the
names and descriptions that can be associated with named objects.
From an application perspective, it is important to retrieve this infor-
mation since the GUI must ensure name length limitations to avoid
DME-generated exceptions.
Once a connection is established, there is a call to start, which is
defined by each console to initialize the graphical display, as shown
at line 18.
The getJDMConnection method creates the factory from its Java
class name, and uses this factory to create the connection. Its code is
presented here:
1. protected final static Connection getJDMConnection(
2.
String iConnectionFactoryImpl,
3.
String iURI, String iUserName, String iPassword)
 
Search WWH ::




Custom Search