Establishing a Connection
Creating a JDBC Data Source
You can create a JDBC data source to connect from your Java application. Creating a JDBC data source based on the CData JDBC Driver for SAP ERP consists of three basic steps:
- Add the driver JAR file to the classpath. The JAR file is located in the lib subfolder of the installation directory. Note that the .lic file must be located in the same folder as the JAR file.
- Provide the driver class. For example:
cdata.jdbc.saperp.SAPERPDriver
- Provide the JDBC URL. For example:
jdbc:saperp:Host=sap.mydomain.com;User=EXT90033;Password=xxx;Client=800;System Number=09;ConnectionType=JCo; or jdbc:cdata:saperp:Host=sap.mydomain.com;User=EXT90033;Password=xxx;Client=800;System Number=09;ConnectionType=JCo;
The second format above can be used whenever there is a conflict in your application between drivers using the same URL format to ensure you are using the CData driver. The URL must start with either "jdbc:saperp:" or "jdbc:cdata:saperp:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting with the RFC APIs
The CData JDBC Driver for SAP ERP uses the SAP RFC interface to connect to an SAP system.
Obtaining the SAP libraries corresponding to your RFC API is required to connect. The CData JDBC Driver for SAP ERP relies on the SAP RFC to execute queries and retrieve data from SAP. The RFC depends on the JCo (Java Connector) JAR file.
Connect Using the JCo JAR File
You will need to include the sapjco3.jar to your path as well as the sapjco3 native library.
In addition, the sapjco3.dll must placed next to the sapjco3.jar. On Linux, this will be the libsapjco3.so file. On Mac OS X, this will be the libsapjco3.jnilib file.
Note: Ensure that you download libraries that match the bitness of your platform.
Required RFCs
The RFCs used by the CData JDBC Driver for SAP ERP are listed as follows. If any listed below are not available, some or all functionality may not work. T-Code SE37 may be used to view available function modules in SAP.
- DDIF_FIELDINFO_GET
- RFC_GET_FUNCTION_INTERFACE
- RFC_GET_STRUCTURE_DEFINITION
- RFC_GET_SYSTEM_INFO
- RFC_GET_UNICODE_STRUCTURE
- RFC_READ_TABLE
- SLDAG_CHECK_FOR_UNICODE
Connecting to SAP ERP
Set the following to connect:
- Host: The host name of the target system. Host names can be regular host names defined in a hosts file, an IP address like 123.123.123.123, or an SAProuter address such as "/H/hostname/S/port/H/host/S/port/ ..."
- User: The user that is authenticating to the SAP system.
- Password: The password used to authenticate to the SAP system.
- Client: The client authenticating to the SAP system.
- SystemNumber: The number by which the target system is defined.
- Language: The ISO 639-1 language code you use to log into SAP ERP. The default is "EN".
To connect to a machine different from the Host machine, substitute Host with the following:
- GatewayHost: The gateway host you wish to connect to. If not specified, the provider will attempt to connect to the SAP system specified by Host.
- GatewayService: The gateway service you wish to connect to. If not specified, the SAP system will use the default "sapgw##" where the "##" is the SystemNumber.
To connect to a distributed system or systems with other configurations, see Fine-Tuning Data Access.
Certificates
In addition to User and Password, the CData JDBC Driver for SAP ERP also supports certificate authentication. To use certificate authentication, set the X509Certificate connection property to either point to a file that contains an X509 certificate in PEM format, or the PEM blob directly used for authentication during SAP Logon. In addition to setting X509Certificate, you will need to specify the appropriate SNC connection properties. The SNC connection properties are described under Fine-Tuning Data Access.