import com.sap.mw.jco.*; ... /* JCO.createClient(SAP_CLIENT, USER_ID, PASSWORD, LANGUAGE, HOST_NAME, SYSTEM_NUMBER); */ JCO.Client connection = JCO.createClient("100", "myuserid", "mypassword", "EN", "mysaphost", "00"); connection.connect(); ... connection.disconnect();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.
GETTING CONNECTED WITH JCO
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
Dig Deeper on SAP Web applications