Hi,
Sure thing, first u have to define ur Services in the PortalApps.xml. Once u do that then u will be on ur way. I attaching the Sample portal apps and also the sample code.
<?xml version="1.0" encoding="utf-8"?>
<application>
<application-config>
<property name="ServicesReference" value="com.sap.portal.htmlb, com.sap.portal.ivs.iviewservice, com.sap.portal.ivs.connectorservice, com.sap.portal.runtime.system.inqmy, com.sap.portal.pcd.glservice, com.sap.portal.ivs.systemlandscapeservice,com.sap.portal.pcmbuilderservice, usermanagement, com.sap.portal.ivs.logger, com.sap.portal.usermapping , landscape, jcoclient"/>
<property name="releasable" value="true"/>
</application-config>
<components>
<component name="empSearch">
<component-config>
<property name="ClassName" value="com.saped.prototype.search.empSearch"/>
<property name="SecurityZone" value="com.saped.prototype.search/high_safety"/>
</component-config>
<component-profile>
<property name="System" value="SAP_ED"/>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
</components>
<services/>
</application>
Above view the <application-config> tags where we have defined the services. Please note the example I will be showing uses the Database with an Alias, just ask ur system admin to mount the database for u as using an Alias is mich more simpler.
private IConnection getJDBCConnection(
String systemAlias,
IPortalComponentRequest request)
throws ConnectorException, Exception {
try {
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime
.getRuntimeResources()
.getService(
IConnectorService.KEY);
if (cgService == null) {
throw new ConnectorException("Error in get Connector Gateway Service");
}
// Use the Connector Gateway to get connection to JDBC DB
ConnectionProperties cp =
new ConnectionProperties(
request.getLocale(),
request.getUser());
return cgService.getConnection(systemAlias, cp);
} catch (NoLogonDataAvailableException e) {
throw new ConnectorException(
"*** No Logon Data supplied: "
+ e.getNestedException().getLocalizedMessage());
} catch (ConnectorException e) {
throw new ConnectorException(
"*** Connector Exception: "
+ e.getLinkedException().getLocalizedMessage());
}
}
This will establish the connection, and this code works very well, so try it out and if u have any difficulties let me know.
Please score my reply, thanks.
Best Wishes,
Emmanuel.
Add a comment