Part 3: Specifying parameters using an external properties file

The third mechanism provided by the JCo API for specifying parameters to the createClient() method is that of passing an external properties file. This technique enables you to completely remove the system parameters from your code and allows you maintain those values in an external configuration file.

The advantage to this technique is obvious, as all SAP system parameters are now centralized and can be maintained within a single properties file. Likewise, the properties file allows you to use all of the available parameters listing in the JCo API.

To use this version of the createClient() method you first create a plain text file (called "" in this example):

In addition to the normal system parameters, I have also specified that RFC trace be enabled and set the idle timeout for this JCo connection to one millisecond. Notice that because the timeout value must be passed to JCo as an integer, it cannot be specified using double quotes. The name attribute must be that which is specified in the JCo API, i.e. "jco.client.lang" is the only name attribute that allows you to specify a language value.

In order to use this properties file, call the createClient() method like this:

import java.util.Properties;



    Requires Free Membership to View

sapProperties = new Properties(); sapProperties.load(new FileInputStream("c:/dev/workspace/busptr/")); JCO.Client connection = JCO.createClient(sapProperties); ... connection.disconnect();
Note that in order to load the properties, you must specify its full filesystem path name. Alternatively, if the properties file exists in the same directory as the Java class being executed, no path name is required. However, this is not recommended due to the varying nature of how your application may be deployed.

In addition, your application can override the default parameters set in the properties file by call the setProperty() method:

sapProperties.setProperty("jco.client.user", "someotherguy");
This is useful when you want to dynamically change settings, such as logging with the RFC trace option or using a login ticket instead of a user ID.


 Home: Introduction
 Part 1: Specifying parameters as single String values
 Part 2: Specifying parameters using a String array
 Part 3: Specifying parameters using an external properties file
 Part 4: Specifying parameters with a custom properties file
 Review: Conclusion and more resources

This was first published in July 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: