on 10-25-2006 4:23 PM
Hi all,
I'm developing an application en webdynpro, where we need connecting to a MaxDB data base. I have trid to opcions: via Connector Service:
IConnection connection = null;
String jdbcSystem = "EPD";
com.sapportals.portal.prt.runtime.PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
String alf = PortalRuntime.getRuntimeResources().toString();
IConnectorGatewayService cgService = (IConnectorGatewayService)PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties cp = new ConnectionProperties(new Locale("ES"),(IPrincipal)WDClientUser.getLoggedInClientUser());
try{
connection = cgService.getConnection(jdbcSystem, cp);
}catch (Exception e){
}finally{
try{
if(connection != null) connection.close();
}catch(Exception re){
}
}
via J2EE:
IConnection connection = null;
IConnectionFactory connectionFactory;
javax.naming.Context initctx = null;
try{
Hashtable env = new Hashtable();
env.put("domain","true");
initctx = new com.sapportals.portal.prt.jndisupport.InitialContext(env);
connectionFactory = (IConnectionFactory)initctx.lookup("deployedAdapters/JDBCFactory/shareable/JDBCFactory");
IConnectionSpec spec = connectionFactory.getConnectionSpec();
spec.setPropertyValue("UserName","control");
spec.setPropertyValue("Password","control");
spec.setPropertyValue("driver","com.sap.portals.jdbc.sqlserver.SWLServerDriver");
spec.setPropertyValue("url","jdbc:sap:sqlserver://localhost:50110;DatabaseName=EPD");
connection = connectionFactory.getConnectionEx(spec);
}catch (Exception e) {
// TODO: handle exception
}finally{
try {
if (connection != null)
connection.close();
} catch (Exception e) {
// TODO: handle exception
}
}
In both cases a get de same error in running de application:
1. First case:
java.lang.NoClassDefFoundError: com/sapportals/portal/prt/jndisupport/PortalRuntime
2. Second case:
java.lang.NoClassDefFoundError: com/sapportals/portal/prt/jndisupport/InitialContext
This happen eventhough I have include
import com.sapportals.portal.prt.runtime.PortalRuntime;
import com.sapportals.portal.prt.jndisupport.InitialContext;
with their corresponding jar files added as 'External Jars' in project's properties:
\JC01\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\portal\lib\prtapi.jar
and \JC01\j2ee\cluster\server0\apps\sap.com\irj\servlet_jsp\irj\root\WEB-INF\lib\prtjndisupport.jar
Can anybody help me?
thanks in advance
Hi,
Use <a href="https://media.sdn.sap.com/javadocs/NW04/SPS15/wd/com/sap/tc/webdynpro/clientserver/portal/WDPortalUtils.html">WDPortalUtils</a>
WDPortalUtils.getServiceReference(IConnectorService.KEY)
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks !! Maksim, it's been a very helpful, it really works.
But i think the rest of my code is not suitable of using WDPortalUtils, so i get the following error:
java.lang.NoClassDefFoundError: com/sap/portal/services/api/connectorgateway/IConnectorGatewayService
when i use:
IConnection connection = null;
String jdbcSystem = "EPD";
IConnectorGatewayService cgService = (IConnectorGatewayService)WDPortalUtils.getServiceReference(IConnectorService.KEY);
ConnectionProperties cp = new ConnectionProperties(new Locale("ES"),(IPrincipal)WDClientUser.getLoggedInClientUser());
connection = cgService.getConnection(jdbcSystem, cp);
Could you please write me a short code in order to get de connection to de MaxDB database? I'm very grateful to you. Thanks
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.