cancel
Showing results for 
Search instead for 
Did you mean: 

JCO Connection constructor: Pool already initialized

Former Member
0 Kudos

Hi Folks,

while i'm configuring a JCO connection to R/3, i got a little problem:

In my class constructor i initialize a client pool.


JCO.addClientPool(sapSID, sapMaxConnections, sapMandant, sapUser, sapPasswort, sapLanguage, sapSystem, sapSystemNumber);

JCO.getClientPoolManager().getPool(sapSID).setMaxWaitTime(maxWaitTime);

problem:

when there is already a client pool, the application crashes

solution:

check if there is already a connection-pool with this name

i tried the following:

1) Check if there's a pool with the name


		if (JCO.getClientPoolManager().getPool(sapSID).getName()==sapSID) {
		...	
		}

==> which leads to a null pointer exception because logically there is no pool and as the doc says "if there's no pool, .getPool(String) will return null, which leads to:

2) Check if null


		if (JCO.getClientPoolManager().getPool(sapSID)==null) {
		...	
		}

but unfortunately. this won't work either.. null point exception again.

anyone got a hint?

thx in advance,

lars

Message was edited by:

Lars Paetzold

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Paste some more code if you want.

Where do you set the waittime? In the if or in the else?

KR,

Christophe

Former Member
0 Kudos

i remove the waittime part now, but it won't work anyway:

java.lang.NullPointerException



if (JCO.getClientPoolManager().getPool(sapSID)==null) {
		
	if (JCO.getClientPoolManager().getPool(sapSID).getName().toString()==sapSID.toString()) {
				
	} else {
		JCO.addClientPool(sapSID, sapMaxConnections, sapMandant, sapUser,
						sapPasswort, sapLanguage, sapSystem, sapSystemNumber);	
	}
			
}

if i'm not checking if there is any kind of pool, everything works fine until i call the application a second time and the pool is already initialized

Former Member
0 Kudos

You are getting the name of the pool when the pool is null. This will lead to a nullpointerexception.

Change

if (JCO.getClientPoolManager().getPool(sapSID)==null) {

to

if (JCO.getClientPoolManager().getPool(sapSID)!=null) {

Former Member
0 Kudos

okay, works fine now i modified it a bit more and here's the code-snippet if a pool is initialized or not, for whom it might interesst:


//Check if there is any pool created with the name sapSID, if not, create one

if (JCO.getClientPoolManager().getPool(sapSID)!=null) {

//There is a Pool, do nothing
		
} else {

//There is no pool, create one
JCO.addClientPool(sapSID, sapMaxConnections, sapMandant, sapUser,sapPasswort, sapLanguage, sapSystem, sapSystemNumber);		

}

Answers (0)