cancel
Showing results for 
Search instead for 
Did you mean: 

SAP JCo 3 connection check

Former Member
0 Kudos

Hi SAP gurus,

Could you please help me with one thing. I'm developing application which communicates with SAP via JCo.I have successfully implemented connection establishing and calling function. What I cannot figure out in JCo 3 is how to check connectivity, to see if the connection is maybe broken for some reason.

I see that in JCo 2 there was class JCO.connection, which has method isAlive() - which checks whether the connection is alive. As far as I can see, in JCo 3 there is no such class. I need that kind of check in my application, because I need to see whether connection is broken before I start one complex process.

I see that ping method exists, but it's quite slow (sometimes it needs several seconds).

Could you please help me regarding this problem?

Thank you all very much for your help!

Accepted Solutions (1)

Accepted Solutions (1)

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Karlo,

Actually, the isAlive method in JCo 2.1 is not really telling whether the connection is alive. It only checks whether the connection handle is still a valid one, which could be the case, even if the connection had been closed by the partner side. The only safe check for the time being that is actually possible is a ping. A check, which is comparable to isAlive() is to use the monitor and check whether there are still connections available for the destination that shall be used.

Best regards,

Markus

Former Member
0 Kudos

Hello Markus,

Thank you very much for your answer!

Yesterday I have found another possible solution, with getting number of active connections via getConnectionsData(). I use something like this:

if (!destination.getMonitor().getConnectionsData().isEmpty()){

                return true;

            }

Do you think that is good approach (since I cannot use ping)?

Thanks for help!

Karlo

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Karlo,

in principle you describe that you've implemented the method via the monitor that I described above. Hence, it's worth as much as isAlive(). If there is no connection available however, you could try with a ping whether connectivty is still working afterwards in case it is really important to know this before. Otherwise, no connection will get back into the pool again

Best regards,

Markus

Former Member
0 Kudos

Thank you very much for help!

Regards,
Karlo

Answers (0)