Rather than using the Business Components Browser, you can also choose to test your Business Components project with the following sample client code for connecting to an AppModule deployed as an EJB session bean to BEA WebLogic:
package mypackage;
import oracle.jbo.*;
import oracle.jbo.client.Configuration;
public class sampleClient
{
public sampleClient()
{
}
public static void main(String arg[])
{
String _am = "mypackage.MypackageModule"; //App Module name
String _wcf = "MypackageModuleWLS"; //Weblogic EJB config name
String voMemberName = "DeptView"; // Name of the View Object
//Use _wcf if you are accessing Business Components application deployed as
//as EJB session bean in weblogic
ApplicationModule myam =
(ApplicationModule)Configuration.createRootApplicationModule(_am,_wcf);
// Find the viewobject included in the appmodule
ViewObject vo = myam.findViewObject(voMemberName);
// Iterate over the viewobject to get the rows
Row r = vo.first();
while (r != null)
{
// Iterate over the current row and get
// all the attributes
for (int i = 0; i vo.getAttributeCount(); i++)
{
String attrName = vo.getAttributeDef(i).getName();
String attrVal = r.getAttribute(i).toString();
System.out.println(attrName + " = " + attrVal);
}
r = vo.next();
}
Configuration.releaseRootApplicationModule(myam, true);
}
}
Note: When redeploying an EJB session facade bean (BMT)
that is not client-enabled, the client code must call
appmodule.remove()
or
appmodule.getTransaction().disconnect()
to close the JDBC
connection. Otherwise an exception occurs.
Copyright © 1997, 2004, Oracle. All rights reserved.