Part 1: Specifying parameters as single String values


JCO.Client connection = JCO.createClient("100", "myuserid", "mypassword", "EN", "mysaphost", "00");

As you can see, the connection code is very simple. In fact, you could simply cut and paste the above code into your own application, replace the string values, and connect to SAP. Obviously, maintaining the system connectivity with this code would be difficult, as you would need to search and manually replace each occurrence of each string value.

A slightly more elegant solution would be to declare each value as a global, class-level variable:

public static final String SAP_CLIENT = "100";
By declaring the value public, you create visibility for this value within any generated Javadoc documentation. By declaring it final and assigning it a value, no other code can modify the value. Of course, by hardcoding the password inside a Java class, you run the risk that someone could decompile the source to get at your plaintext password. This connection technique should only be used in development situations, where strong security is not a priority.


 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: