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 HANA 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.saphana.SAPHANADriver
- Provide the JDBC URL. For example:
jdbc:saphana:User=system;Password=mypassword;Server=localhost;Database=systemdb; or jdbc:cdata:saphana:User=system;Password=mypassword;Server=localhost;Database=systemdb;
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:saphana:" or "jdbc:cdata:saphana:" and can include any of the connection properties in name-value pairs separated with semicolons.
Connecting to SAP HANA Cloud
Set the following to connect to data:- Server: Set this property to the name or network address of the SAP HANA database instance.
- Port: Set this to 443.
- UseSSL: Set this to True.
Connecting to SAP HANA On-Prem
Set the following to connect to data:
- Server: Set this property to the name or network address of the SAP HANA database instance.
- Port: The port of the server hosting the SAP HANA database.
Authenticating to SAP HANA
Once you have provided the connection details, set the following database credentials to authenticate to SAP HANA:
- User: The username provided for authentication with the SAP HANA database.
- Password: The password provided for authentication with the SAP HANA database.
Okta
Set the AuthScheme to Okta. The following connection properties are used to connect to Okta:
- User: Set this to the Okta user.
- Password: Set this to Okta password for the user.
- SSOProperties (optional): Set this to the OTP code that was sent to your device. This property should be used only when MFA is required for OKTA sign on.
The following SSOProperties are needed to authenticate to Okta:
- SSOLoginUrl: Set this to the OKTA's login URL.
- MFAType (optional): Set this to the multi-factor type. This property should be used only when MFA is required for OKTA sign on. This property accepts one of the following values:
- OKTAVerify
- SMS
- APIToken (optional): Set this to the API Token that the customer created from the Okta org. It should be used when authenticating a user via a trusted application or proxy that overrides OKTA client request context.
The following is an example connection string:
AuthScheme=OKTA;User=username;Password=password;Server=myserver;SSO Properties='SSOLoginUrl=https://cdata-okta.okta.com';