on 09-21-2007 1:16 PM
Hi guys,
I have tried some sample code in Jco. For this I have created a java project and created a java class ConnectionPool
import com.sap.mw.jco.*;
public class ConnectionPool extends Object
{
static final String POOL_NAME = "Pool";
JCO.Client mConnection;
public ConnectionPool() {
try {
JCO.Pool pool = JCO.getClientPoolManager().getPool(POOL_NAME);
if (pool == null) {
OrderedProperties logonProperties =
OrderedProperties.load("/logon.properties");
JCO.addClientPool(POOL_NAME, // pool name
5, // maximum number of connections
logonProperties); // properties
}
mConnection = JCO.getClient(POOL_NAME);
System.out.println(mConnection.getAttributes());
}
catch (Exception ex) {
ex.printStackTrace();
}
finally {
JCO.releaseClient(mConnection);
}
}
public static void main (String args[]) {
ConnectionPool app = new ConnectionPool();
}
}
And I have created OrderedProperties.java class to read the logon.properties
public class OrderedProperties extends java.util.Properties
{
ArrayList orderedKeys = new ArrayList();
public OrderedProperties()
{
super();
}
public OrderedProperties(java.util.Properties defaults)
{
super(defaults);
}
public synchronized Iterator getKeysIterator()
{
return orderedKeys.iterator();
}
public static OrderedProperties load(String name)
throws IOException
{
OrderedProperties props = null;
java.io.InputStream is =
OrderedProperties.class.getResourceAsStream(name);
if ( is != null )
{
props = new OrderedProperties();
props.load(is);
return props;
} else
{
if ( ! name.startsWith("/") )
{
return load("/" + name);
} else {
throw new IOException("Properties could not be loaded.");
}
}
}
public synchronized Object put(Object key, Object value)
{
Object obj = super.put(key, value);
orderedKeys.add(key);
return obj;
}
}
And a logon.properties simple file with these client credentials
jco.client.client
jco.client.user
jco.client.passwd
jco.client.ashost
jco.client.sysnr
I m getting this error
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM GWHOST=172.18.3.81, GWSERV=sapgw95, ASHOST=172.18.3.81, SYSNR=95
LOCATION CPIC (TCP/IP) on local host
ERROR partner not reached (host 172.18.3.81, service 3395)
TIME Fri Sep 21 17:28:54 2007
RELEASE 640
COMPONENT NI (network interface)
VERSION 37
RC -10
MODULE nixxi_r.cpp
LINE 8672
DETAIL NiPConnect2
SYSTEM CALL SiPeekPendConn
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 1
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1098)
at com.sap.mw.jco.JCO$Client.connect(JCO.java:2983)
at com.sap.mw.jco.JCO$Pool.initPool(JCO.java:4375)
at com.sap.mw.jco.JCO$PoolManager.getClient(JCO.java:5748)
at com.sap.mw.jco.JCO$PoolManager.getClient(JCO.java:5703)
at com.sap.mw.jco.JCO.getClient(JCO.java:7931)
at ConnectionPool.<init>(ConnectionPool.java:30)
at ConnectionPool.main(ConnectionPool.java:41)
Hi,
First check your connection to the SAP server (ping IP-Address). If it works check your etc/services file that there is an entry for the gateway you want to connect to.
You should have following entries:
sapgw<SYSNO> 32<SYSNO>/tcp
sapdp<SYSNO> 33<SYSNO>/tcp
sapmsy<SID> 36<SYSNO>/tcp
And there must be a blank line at the end of the file!!!!
Regards,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am able to ping the ip address, and a following entry sapdp and sapgw entries are there in my service file but I am not able to find sapmsy. But can you clarify what are these 32,33,36 and sapgw,sapdp,sapmsy, jus to get more info on it. Still I am unable to connect to sap gateway.
Kindly help
Regards,
PP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
btw wht is etc/services file??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
no im unbale 2 ping the IP adress fro my system but i can from my collegues's system.but i have 2 work on my system so canu help wht setting i have 2 confgure in order to work on my system
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
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.