Skip to Content
author's profile photo
Former Member

Connecting to MSSQL using JCA

Hi,

Can any one help me by providing detailed information regarding connecting to MSSQL using JCA.

Do we need any Resource Adapters(.rar) files to be deployed on to the server.If so please guide me.

Thanx in Advance,

Santhosh

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    author's profile photo
    Former Member
    Posted on Dec 22, 2004 at 07:55 AM

    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 comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Emmanuel,

      Thanks for responding.The method u gave is correct.It works fine,with that method I already did

      an example which connects R3 system.As I mentioned

      in previous post.I need information regarding .rar files

      and deploy tool.I was trying to deploy jdbcconnector.rar file using deploy tool but could not do it.

      I am trying an example containing this line.

      connectionFactory = (IConnectionFactory)initctx.lookup("EISConnections/JDBCFactory");

      To execute this line,I think we need to deploy .rar files with deploy tool.But I am unable to do so..

      Do u have any idea in this regard.Help me

      Thanks,

      SANTHOSH