IBM Tivoli Software IBM Tivoli Software

[ Bottom of Page | Previous Page | Next Page | Contents ]


Examples: working with objects in the database

The following examples indicate how you use the classes to work with objects in the database:

Example 1: adding a workstation to the database

//Object definition
String wksName = "MYWS";
Workstation wks = new Workstation();
wks.setName(wksName);
wks.setType(WorkstationType.FTA);
wks.setOs(OperatingSystem.UNIX);
wks.setAutoLink(true);
wks.setNodeName("node.ibm.com");
wks.setSecurityLevel(SecurityLevel.NONE);
		 		 

ConnModel myModel;
//Get an instance of ConnModel interface...
...
		 		 
//Add the object
try 
{    
		 myModel.addTWSObject(wks, null);
}
catch (ConnException e) 
{
		 //Do something to recover...
}

Example 2: retrieving a workstation from the database

Workstation wksRead = new Workstation();
//Get the same workstation from the DB
try 
{
		 wksRead = (Workstation) myModel.getTWSObject(Workstation.class, new FlowTargetKey(wksName), false, null);
}
catch (ConnException e) 
{
		 //Do something to recover...
 }

Example 3: removing a workstation from the database

//Remove a workstation from the DB
 try 
{
		 myModel.removeTWSObject(Workstation.class, wksRead.getId(), null);
}
catch (ConnException exc)
{
		 //Do something to recover...
}

[ Top of Page | Previous Page | Next Page | Contents ]