To configure a data source using the example files, you will need to create a data source definition. The content required to create a data source definition is divided into three sections.

First, you will need to import the data source class. For example:

import com.ddtek.jdbcx.s4hana.S4HanaDataSource;
Note: The data source class to be imported is the same for all SAP ODATA V2 services exposed through the SAP Gateway, including S/4HANA and BW/4HANA.

Next, you will need to set the values and define the data source. For example, the following definition contains the minimum properties required for a connection using the basic authentication method.

Note:
  • Setting the password using a data source is generally not recommended. The data source persists all properties, including the Password property, in clear text.
  • In a JDBC data source, string values must be enclosed in double quotation marks, for example, setUser("abc@defcorp.com").
S4HanaDataSource mds = new S4HanaDataSource();
mds.setDescription("My S4Hana Data Source");
mds.setServerName("mycompany.s4hana.ondemand.com");
mds.setUser("username");
mds.setPassword("password");

Finally, you will need to configure the example application to print out the data source attributes. Note that this code is specific to the driver and should only be used in the example application. For example, you would add the following section for the minimum properties required to establish a connection:

if (ds instanceof S4HanaDataSource)
{
S4HanaDataSource jmds = (S4HanaDataSource) ds;
System.out.println("description=" + jmds.getDescription());
System.out.println("servername=" + jmds.getServerName());
System.out.println("user=" + jmds.getUser());
System.out.println("password=" + jmds.getPassword());
...
System.out.println();
}