Hi,
I have written a program which retieves data from two back ends
1.SQL
2.SAP R/3
I have used connector gateway service to connect to the 2 systems
craeted two aliases for both the systems
And trying to access them.
java.sql.Connection connection = null;
// get the Connector Gateway Service
String jdbcSystem = "lok_jdbc";
// SAP ERP system which has BUS1001 as BOR object representing material
String sapSystem = "RT1";
String[] sysAliases = new String[]{jdbcSystem, sapSystem};
IConnectorGatewayService cgService = (IConnectorGatewayService)
PortalRuntime.getRuntimeResources().getService( IConnectorService.KEY);
ConnectionProperties cp = new ConnectionProperties(request.getLocale(),
request.getUser());
try {
connection = cgService. getDistributedConnection(sysAliases,cp);
Statement statement = connection.createStatement();
// (a dummy query)
String queryStr = "SELECT * FROM lok_jdbc.dbo.employee where lok_jdbc.dbo.employee.fname = 'Paolo'";
java.sql.ResultSet rs = statement.executeQuery(queryStr);
while ( rs.next() ) {
String lastName = rs.getString(1);
String lastName1 = rs.getString(0);
String lastName2 = rs.getString(2);
response.write(lastName);
response.write(lastName1);
response.write(lastName2);
}
// consume the java.sql.ResultSet in JDBC API
} catch (Exception e) {
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException re) {
response.write(re.getLocalizedMessage());
}
}
Thanks & Regards,
Lokesh.