Java and SAP - Connnecting via the Java Connector (JCo)

4,285 views
Skip to first unread message

bsk

unread,
Nov 8, 2008, 5:04:12 AM11/8/08
to vogella, lars....@googlemail.com
Hi,

Thanks for the nice article on Java and SAP connection.

I have read your article from http://www.vogella.de/articles/SAPJCo/article.html,
it say the article is based on SAP JCo connector 3.0 and Java 1.5.

But, the example doesn't compile with JCo 3.0 as the package
structures are different.

Currently I'm upgrading my SAP JCo from 2.1.8 to 3.0.0 to support Java
1.5.

It will be a great help if you can post the latest version of the
article (SAP JCo 3.0 and Java 1.5).

Thanks in advance,
Raj

vogella

unread,
Nov 8, 2008, 5:26:36 AM11/8/08
to vogella
Hi Raj,

yes, I'm currently in the process of updating this article to JCo 3.0,
that is the reason why is article is currently in DRAFT.

The plan is to finish this within the next week. I'll post an update
to this thread once I'm down.

Best regards, Lars

On 8 Nov., 11:04, bsk <basavaraj.ka...@gmail.com> wrote:
> Hi,
>
> Thanks for the nice article on Java and SAP connection.
>
> I have read your article fromhttp://www.vogella.de/articles/SAPJCo/article.html,

denn...@gmail.com

unread,
Jan 5, 2009, 11:18:53 AM1/5/09
to vogella
Is this sample is completely updated??
It seems like the code snippet still uses com.sap.mw.* package, which
is no longer available in the new jar (sapjco3.jar), the connection
interface is completely redone it seems. DO you have the updated
sample with correct code snippet??
thanks,
--Denny


On Nov 8 2008, 5:26 am, vogella <Lars.Vo...@googlemail.com> wrote:
> Hi Raj,
>
> yes, I'm currently in the process of updating this article toJCo3.0,
> that is the reason why is article is currently in DRAFT.
>
> The plan is to finish this within the next week. I'll post an update
> to this thread once I'm down.
>
> Best regards, Lars
>
> On 8 Nov., 11:04, bsk <basavaraj.ka...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > Thanks for the nice article on Java and SAP connection.
>
> > I have read your article fromhttp://www.vogella.de/articles/SAPJCo/article.html,
> > it say the article is based on SAPJCoconnector 3.0 and Java 1.5.
>
> > But, the example doesn't compile withJCo3.0 as the package
> > structures are different.
>
> > Currently I'm upgrading my SAPJCofrom 2.1.8 to 3.0.0 to support Java
> > 1.5.
>
> > It will be a great help if you can post the latest version of the
> > article (SAPJCo3.0 and Java 1.5).
>
> > Thanks in advance,
> > Raj- Hide quoted text -
>
> - Show quoted text -

Lars Vogel

unread,
Jan 5, 2009, 11:29:35 AM1/5/09
to vog...@googlegroups.com
I didn't found the time yet to update it.... Thank you for the reminder, I'll try to update it soon and post to this thread once I'm done. Hopefully this time I will find the time....

2009/1/5 <denn...@gmail.com>



--
Lars
http://www.vogella.de - Tutorial about Java, Eclipse and Web programming
Message has been deleted

vogella

unread,
Jan 26, 2009, 5:03:20 PM1/26/09
to vogella
Hi,
finally I made it. The article is now updated to SAP JCo 3.0.

http://www.vogella.de/articles/SAPJCo/article.html

It is just a small example but might be enought to get started.

Sorry for the the delay.

Best regards, Lars

On 5 Jan., 17:29, "Lars Vogel" <lars.vo...@googlemail.com> wrote:
> I didn't found the time yet to update it.... Thank you for the reminder,
> I'll try to update it soon and post to this thread once I'm done. Hopefully
> this time I will find the time....
>
> 2009/1/5 <dennyj...@gmail.com>
> Larshttp://www.vogella.de- Tutorial about Java, Eclipse and Web programming

abys...@gmail.com

unread,
Feb 4, 2009, 1:22:39 PM2/4/09
to vogella
Hi,

I'm new to SAP JCO when i tried your sample program with the following
conf

jco.client.lang=en
jco.client.client=XXX
jco.client.passwd=xxxxxxx
jco.client.user=username
jco.client.sysnr=XX
jco.client.ashost=IP

and while i'm accessing any method of the JCoDestination instance i'm
getting the following error

Caused by:
RfcException: [System <empty>[AS_HOST/SYSNR]
message: Handle close pending
Return code: RFC_CLOSED(6)
error group: 109
key: RFC_ERROR_CANCELLED
at com.sap.conn.rfc.engine.RfcIoOpenCntl.RfcIsValidHandle
(RfcIoOpenCntl.java:2044)
at com.sap.conn.rfc.engine.RfcIoOpenCntl.RfcReceive
(RfcIoOpenCntl.java:1880)
at com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:180)
at com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect
(MiddlewareJavaRfc.java:1263)
... 24 more

Can you please look into this.
> > Larshttp://www.vogella.de-Tutorial about Java, Eclipse and Web programming

Lars Vogel

unread,
Feb 4, 2009, 3:06:41 PM2/4/09
to vog...@googlegroups.com
Hi, 

you find a working example here: 


Best regards, Lars




--
Lars
http://www.vogella.de - Tutorial about Java, Eclipse and Web programming

Dave Gruska

unread,
Feb 16, 2009, 11:43:35 AM2/16/09
to vogella
Lars,
I'm getting the same type of error w/ the link you provided:

Exception Details: com.sap.conn.rfc.exceptions.RfcException
Handle close pending

Possible Source of Error:
Class Name: com.sap.conn.rfc.engine.RfcIoOpenCntl
File Name: RfcIoOpenCntl.java
Method Name: RfcIsValidHandle
Line Number: 2044

Stack Trace:
com.sap.conn.rfc.engine.RfcIoOpenCntl.RfcIsValidHandle
(RfcIoOpenCntl.java:2044)
com.sap.conn.rfc.engine.RfcIoOpenCntl.RfcReceive(RfcIoOpenCntl.java:
1880)
com.sap.conn.rfc.api.RfcApi.RfcOpen(RfcApi.java:180)
com.sap.conn.jco.rt.MiddlewareJavaRfc$JavaRfcClient.connect
(MiddlewareJavaRfc.java:1263)
com.sap.conn.jco.rt.ClientConnection.connect(ClientConnection.java:
661)
com.sap.conn.jco.rt.PoolingFactory.init(PoolingFactory.java:103)
com.sap.conn.jco.rt.ConnectionManager.createFactory
(ConnectionManager.java:171)
com.sap.conn.jco.rt.DefaultConnectionManager.createFactory
(DefaultConnectionManager.java:44)
com.sap.conn.jco.rt.ConnectionManager.getFactory
(ConnectionManager.java:160)
com.sap.conn.jco.rt.RfcDestination.initialize(RfcDestination.java:766)
com.sap.conn.jco.rt.RfcDestination.getAttributes(RfcDestination.java:
618)
com.sap.conn.jco.rt.RfcDestination.getAttributes(RfcDestination.java:
26)
testapp.Connection.(Connection.java:47)

Any ideas?

Thanks in advance,
Dave

On Feb 4, 3:06 pm, Lars Vogel <lars.vo...@googlemail.com> wrote:
> Hi,
> you find a working example here:
>
> http://www.vogella.de/articles/SAPJCo/article.html
>
> Best regards, Lars
>
> 2009/2/4 <abysam...@gmail.com>
> > > > Larshttp://www.vogella.de-Tutorialabout Java, Eclipse and Web
> > programming
>
> --
> Larshttp://www.vogella.de- Tutorial about Java, Eclipse and Web programming

Lars Vogel

unread,
Feb 16, 2009, 4:08:54 PM2/16/09
to vog...@googlegroups.com
Hi Dave,

can you paste the line 47 of Class Connection?

Best regards, Lars

2009/2/16 Dave Gruska <grus...@gmail.com>



--
Lars
http://www.vogella.de - Tutorial about Java, Eclipse and Web programming

asav...@gmail.com

unread,
Feb 24, 2009, 2:36:53 AM2/24/09
to vogella
Hi Lars,
I have a problem deploying my application on the server without
restarting it, it gives me the next message:

Error 500: com.sap.conn.rfc.driver.RfcTypeDirectCpic (initialization
failure).

The truth is that the first time I deploy the application there is no
problem at all, but the rest of times it shows me the above message. I
do not know what could be the problem because I have done the
connection exactly as you posted. I have a java application (Jdk 1.5)
trying to connect to SAP, meantime through the Jco 3.0.

By the way, I have in parallel another problem sending BCD parameters,
via BAPI. These are really special parameters and SAP does not receive
them properly, do you know any way to send and receive them?

Thank you very much.

Lars Vogel

unread,
Feb 24, 2009, 3:07:39 AM2/24/09
to vog...@googlegroups.com
Hi,

sorry, never had this problem. Best regards, Lars

2009/2/24 <asav...@gmail.com>

asav...@gmail.com

unread,
Feb 24, 2009, 7:33:03 AM2/24/09
to vogella
Hi again Lars,
I have seen in SAP that just in the moment of the deployment
on the server there are some pending connections in SAP, these
might influence on the result of the deployment.
Therefore, I would like to cut them, ¿Do you know how to close
"manually" these open connections? ¿Is there any function to do it?

Thanks!

Asbjørn

unread,
Apr 8, 2009, 5:00:26 AM4/8/09
to vogella
Hi
Did you find the problem. I'm experiencing the same problems.?
The connection works if I just use a persisted properties file.
Thanks in advance
/Asbjørn

On 16 Feb., 23:08, Lars Vogel <lars.vo...@googlemail.com> wrote:
> Hi Dave,
>
> can you paste the line 47 of Class Connection?
>
> Best regards, Lars
>
> 2009/2/16 Dave Gruska <grusk...@gmail.com>
> > > > > > Larshttp://www.vogella.de-TutorialaboutJava, Eclipse and Web
> > > > programming
>
> > > --
> > > Larshttp://www.vogella.de-Tutorial about Java, Eclipse and Web

Asbjørn

unread,
Apr 8, 2009, 7:50:46 AM4/8/09
to vogella
Nevermind... turned out to be a simple typo
> > > > Larshttp://www.vogella.de-Tutorialabout Java, Eclipse and Web

viveka...@gmail.com

unread,
Apr 15, 2009, 2:39:45 PM4/15/09
to vogella
Hi,
I am using your code and it is working fine but I am also using
SAP connector provided by oracle.So,I want to close the connection,
can u tell me how to close
the connection in your code case!!


Lars Vogel

unread,
Apr 15, 2009, 3:07:12 PM4/15/09
to vog...@googlegroups.com
I have no knowledge about the Oracle connector.



viveka...@gmail.com

unread,
Apr 16, 2009, 12:06:46 AM4/16/09
to vogella
I m using your connector for JCO i just need to close the JCO
connection ? how i can do it?
I cant use mConnection as that class import.sap.mw,,, is not in SAP
Jco3.jar.. Can you tell me how to close the connection and class for
it



On Apr 15, 2:07 pm, Lars Vogel <lars.vo...@googlemail.com> wrote:
> I have no knowledge about the Oracle connector.
>
> 2009/4/15 <vivekaaaj...@gmail.com>
>
>
>
> > Hi,
> >     I am using your code and it is working fine but I am also using
> > SAP connector provided by oracle.So,I want to close the connection,
> > can u tell me how to close
> > the connection in your code case!!
>
> --
> Larshttp://www.vogella.de- Tutorial about Java, Eclipse and Web programming
Message has been deleted

vishal...@gmail.com

unread,
Apr 16, 2009, 2:58:38 AM4/16/09
to vogella
Hi Lars,

Your article was very helpful, thanks a lot.

But I have got 1 issue. In com.sap.mw.* package, there is method
"disconnect()" in com.sap.mw.jco.JCO.Client for closing the connection
to the remote system.

I tried looking for the similar method in sapjco3.jar but with no
success.

Can you please let me know if there is any similar method available
for closing the connection in sapjco3.jar or any alternate way to
close the connection.

Appreciate all your help.

Thanks,
Vishal
> > Larshttp://www.vogella.de-Tutorial about Java, Eclipse and Web programming

Ridvan

unread,
Apr 16, 2009, 8:18:09 AM4/16/09
to vogella
Hi,

Everbody receiving an error like handle close pending should check
their user if this is blocked in SAP, try again and report it here.

We have tested a failing JCO 3 connection to a SAP system with JCO 2
and received the following error message (lang=de)

com.sap.mw.jco.JCO$Exception: (103) RFC_ERROR_LOGON_FAILURE:
Kennwortanmeldung nicht mehr möglich - zuviele Fehlversuche!

That means "Password logon not possible - too many unsuccessful
logins".

I haven't tested it yet because the user has not been reset yet.
Reply all
Reply to author
Forward
0 new messages