cancel
Showing results for 
Search instead for 
Did you mean: 

How to get DB Connection using IConnectorService

Former Member
0 Kudos

Hi All

I need some documents or help on how to make a jdbc connection using IConnectorService framework. Can anybody help?

Warm Regards

Shubhadip

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Shubhadip,

However, I have forgot to inform you that the connection must be closed when there is no need for it, e.g. as in the former code the closing will be:

try {

myconnection.close();

}

catch (ResourceException e2) {

e2.printStackTrace();

}

Former Member
0 Kudos

Hi Shubhadip,

I have some usefull code for you.

//This method is to perform the connection to the DataBase, where

// the Database name is myDatabase

public IConnection getConnect()

{

IConnection myconnection = null;

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

Object connectorservic = PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);

IConnectorGatewayService cgService = (IConnectorGatewayService)connectorservic;

mylogger = request.getLogger();

ConnectionProperties cp = new ConnectionProperties(request.getLocale(), request.getUser());

try {

myconnection = cgService.getConnection("myDatabase", cp);

}

catch (Exception e)

{

mylogger.severe(e.getMessage());

}

return myconnection;

}

Kind Regards,

Al-Suwaiyel