on 2009 Feb 12 11:08 PM
hi gurus
i need help, i make a JDBC connector in visual administrator
1.- add driver
2.- creat data source
driver clas good
database url good
user and pass good
next tab
in the section SQL engine
ihave to select vendor SQL because in the nex tab DB Initialitation
i execute a simple query selec * from xtabla the result is succesfully but a select
open o native SQL the query send me an error
then in my portal i create a JDBC SYSTEM with the same parameter
create a aliase and mapping system with user an pass when i test connection, it is succesfully
Up to here everything is successful
i develop a JDBC connection
I invoke my database
/*
client = cgService.getConnection("SIG09", prop);
*/
package com.sap.training;
import com.sapportals.portal.prt.component.*;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import com.sapportals.connector.ConnectorException;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.objects.INativeQuery;
import com.sapportals.connector.execution.objects.InvalidQueryStringException;
import com.sapportals.connector.execution.objects.QueryExecutionException;
import com.sapportals.connector.metadata.CapabilityNotSupportedException;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
import com.sapportals.portal.prt.resource.ResourceException;
import com.sapportals.portal.prt.runtime.PortalRuntime;
public class JDBC extends AbstractPortalComponent
{
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
// Open a connection
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime
.getRuntimeResources()
.getService(
IConnectorService.KEY);
ConnectionProperties prop =
new ConnectionProperties(request.getLocale(), request.getUser());
IConnection client = null;
try {
response.write("prueba1");
client = cgService.getConnection("SIG09", prop);
} catch (Exception e) {
response.write(e.toString());
return;
}
try {
response.write("prueba2");
// Issue SQL Query statement
INativeQuery query = client.newNativeQuery();
String queryStr =
"SELECT * FROM compania";
Object result = query.execute(queryStr);
// Iterate returned result
ResultSetMetaData recordMetaData =
((ResultSet) result).getMetaData();
response.write("prueba3");
int colNum = recordMetaData.getColumnCount();
// result.beforeFirst();
response.write("<table border=1>");
while (((ResultSet) result).next()) {
response.write("<tr>");
for (int i = 1; i <= colNum; i++) {
response.write("<td>" +
((ResultSet) result).getString(i)+ "</td> </tr>");
}
}
// Close the connection
client.close();
} catch (QueryExecutionException e) {
response.write(e.toString());
} catch (CapabilityNotSupportedException e) {
response.write(e.toString());
} catch (ConnectorException e) {
response.write(e.toString());
} //catch (InvalidQueryStringException e) {
//response.write(e.toString());
catch (ResourceException e) {
response.write(e.toString());
} catch (SQLException e) {
response.write(e.toString());
} catch (Exception e) {
response.write(e.toString());
}
}
}
then i create an iview for par file the portal throws this error
#1.5 #001143302F1E00770000001E00001358000462C060CBEF7C#1234478304145#com.sap.portal.prt.runtime#sap.com/irj#com.sap.portal.prt.runtime#JSBAUTISTA#500##SanbornsBI44_BI7_38244650#Guest#a1462c90f95511ddc4b2001143302f1e#SAPEngine_Application_Thread[impl:3]_36##0#0#Error##Java###10:38_12/02/09_0002_38244650
[EXCEPTION]
#1#java.lang.NoClassDefFoundError: com/sap/portal/services/api/connectorgateway/IConnectorGatewayService
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getInstanceInternal(PortalComponentItemFacade.java:228)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getComponentInstance(PortalComponentItemFacade.java:160)
at com.sapportals.portal.prt.core.broker.PortalComponentItem.getComponentInstance(PortalComponentItem.java:732)
at com.sapportals.portal.prt.component.PortalComponentContext.getComponent(PortalComponentContext.java:103)
at com.sapportals.portal.prt.component.PortalComponentContext.init(PortalComponentContext.java:242)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.refresh(PortalComponentContextItem.java:271)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.getContext(PortalComponentContextItem.java:316)
at com.sapportals.portal.prt.component.PortalComponentRequest.getComponentContext(PortalComponentRequest.java:387)
at com.sapportals.portal.prt.connection.PortalRequest.getRootContext(PortalRequest.java:488)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:607)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:524)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:407)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)
#
somebody can help me
thanks
atte
salvatore
Hi,
Probably you missed the reference to ConnectorService in portalapp.xml.
Add the below entry under <application-config>
<property name="ServicesReference" value="com.sap.portal.ivs.connectorservice"/>
Hope this solves your problem
Rgds,
Santhosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guru is the way to the solution in the course ep 120 of sap i can the correct answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.