# SAP HANA Connection

> Source: https://docs.synthesized.io/tdk/latest/user_guide/070_integrations/sap/sap_hana
> For the complete documentation index, see [llms.txt](https://docs.synthesized.io/llms.txt).

Configure connections to SAP HANA databases for source and target data operations.

## Overview

The Synthesized Platform connects to SAP HANA using JDBC. Both source (input) and target (output) connections are configured as data sources in the platform. This covers SAP HANA 2.0 and later, used in both SAP S/4HANA and SAP ECC landscapes with SAP HANA as the underlying database.

## Connection Configuration

### JDBC URL Format

```
jdbc:sap://hostname:port/?databaseName=SYSTEMDB
```

**Components:**

 
| Component | Description |
| --- | --- |
| 
`hostname`

 | 

SAP HANA server hostname or IP address

 |
| 

`port`

 | 

Instance port (typically 3\`<instance>\`15, e.g., 39015 for instance 90)

 |
| 

`databaseName`

 | 

Database name (SYSTEMDB or tenant database name)

 |

### Common Port Numbers

 
| Instance | Port |
| --- | --- |
| 
Instance 00

 | 

30015

 |
| 

Instance 01

 | 

30115

 |
| 

Instance 02

 | 

30215

 |
| 

Instance 90

 | 

39015

 |

### Connection Examples

#### Single-Container System

```
jdbc:sap://saphana.company.com:30015
```

#### Multi-Tenant Database Container (MDC)

Multi-Tenant Database Container (MDC) — SAP HANA’s architecture for hosting multiple isolated tenant databases on a single system.

```
jdbc:sap://saphana.company.com:30015/?databaseName=TENANT01
```

#### With SSL/TLS

```
jdbc:sap://saphana.company.com:30015/?encrypt=true&validateCertificate=true
```

## Adding a Data Source

### Via the UI

1. Navigate to **Data Sources** in the main menu
2. Click **Add Data Source**
3. Select **SAP HANA** as the database type
4. Enter connection details:
  
  - **Name**: Descriptive name (e.g., "SAP Production")
  - **JDBC URL**: Connection string
  - **Username**: Database user
  - **Password**: User password
5. Click **Test Connection** to verify
6. Click **Save**

## Required Permissions

### Source Database (Read)

```sql
-- Create user for TDK
CREATE USER TDK_USER PASSWORD "secure_password";

-- Grant schema read access
GRANT SELECT ON SCHEMA SAP_SCHEMA TO TDK_USER;

-- Grant system view access for metadata
GRANT SELECT ON SYS.SCHEMAS TO TDK_USER;
GRANT SELECT ON SYS.TABLES TO TDK_USER;
GRANT SELECT ON SYS.TABLE_COLUMNS TO TDK_USER;
GRANT SELECT ON SYS.CONSTRAINTS TO TDK_USER;
GRANT SELECT ON SYS.INDEXES TO TDK_USER;
GRANT SELECT ON SYS.REFERENTIAL_CONSTRAINTS TO TDK_USER;
```

### Target Database (Write)

```sql
-- Create user for TDK
CREATE USER TDK_USER PASSWORD "secure_password";

-- Grant full access to target schema
GRANT ALL PRIVILEGES ON SCHEMA TARGET_SCHEMA TO TDK_USER;

-- Or create schema if needed
GRANT CREATE SCHEMA TO TDK_USER;

-- For schema creation mode
GRANT CREATE ANY ON SCHEMA TARGET_SCHEMA TO TDK_USER;
```

### Same-System Deployment

When input and output are on the same SAP HANA system:

```sql
-- User needs read on source schema
GRANT SELECT ON SCHEMA SAP_PROD TO TDK_USER;

-- User needs write on target schema
GRANT ALL PRIVILEGES ON SCHEMA SAP_TEST TO TDK_USER;
```

## Connection Properties

### Security Properties

  
| Property | Description | Default |
| --- | --- | --- |
| 
`encrypt`

 | 

Enable SSL/TLS encryption

 | 

false

 |
| 

`validateCertificate`

 | 

Validate server certificate

 | 

true

 |
| 

`hostNameInCertificate`

 | 

Expected hostname in certificate

 | 

hostname

 |
| 

`trustStore`

 | 

Path to trust store file

 | 

\-

 |
| 

`trustStorePassword`

 | 

Trust store password

 | 

\-

 |

### Performance Properties

  
| Property | Description | Default |
| --- | --- | --- |
| 
`packetSize`

 | 

Network packet size

 | 

131072

 |
| 

`statementCacheSize`

 | 

Prepared statement cache size

 | 

1024

 |
| 

`reconnect`

 | 

Auto-reconnect on failure

 | 

true

 |

### Example with Properties

```
jdbc:sap://saphana.company.com:39015/?encrypt=true&packetSize=262144&reconnect=true
```

## Same-System Configuration

When using the same SAP HANA system for input and output with different schemas:

## SSL/TLS Configuration

### Trust Store Setup

1. Export the SAP HANA server certificate
2. Import into a Java trust store:

```bash
keytool -import -alias saphana \
  -file saphana_cert.pem \
  -keystore truststore.jks \
  -storepass changeit
```

### Connection String with Trust Store

```
jdbc:sap://saphana.company.com:39015/?encrypt=true&trustStore=/path/to/truststore.jks&trustStorePassword=changeit
```

### Via Environment Variables

```bash
export JAVAX_NET_SSL_TRUSTSTORE=/path/to/truststore.jks
export JAVAX_NET_SSL_TRUSTSTOREPASSWORD=changeit
```

## Troubleshooting

### Connection Refused

**Symptoms:** Unable to connect, connection refused error

**Solutions:**

1. Verify hostname and port are correct
2. Check network connectivity: `telnet hostname port`
3. Verify SAP HANA is running: `sapcontrol -function GetProcessList`
4. Check firewall rules allow the connection

### Authentication Failed

**Symptoms:** Invalid credentials error

**Solutions:**

1. Verify username and password
2. Check user is not locked: `SELECT * FROM SYS.USERS WHERE USER_NAME = 'TDK_USER'`
3. Reset password if needed: `ALTER USER TDK_USER PASSWORD "new_password"`

### Permission Denied

**Symptoms:** Insufficient privileges error

**Solutions:**

1. Review required permissions above
2. Grant missing permissions
3. Verify schema names are correct

```sql
-- Check user permissions
SELECT * FROM SYS.EFFECTIVE_PRIVILEGES
WHERE USER_NAME = 'TDK_USER';
```

### SSL Handshake Failed

**Symptoms:** SSL/TLS error during connection

**Solutions:**

1. Verify certificate is valid and not expired
2. Check trust store contains the correct certificate
3. Ensure `validateCertificate=false` for self-signed certificates (not recommended for production)

### Slow Connection

**Symptoms:** Connection takes long time to establish

**Solutions:**

1. Check network latency to SAP HANA server
2. Increase packet size for better throughput
3. Consider connection pooling settings

## Best Practices

### Use Dedicated Users

Create separate database users for TDK:

- Different users for different environments
- Minimal permissions required
- Easy to audit and revoke

### Secure Credentials

Store passwords securely:

- Use secret managers (HashiCorp Vault, AWS Secrets Manager)
- Never store plain text passwords
- Rotate credentials periodically

[Learn about Secret Managers →](https://docs.synthesized.io/tdk/latest/user_guide/070_integrations/secret_management/secret_managers)

### Test Connections Before Workflows

Always test connections before creating workflows:

- Use "Test Connection" button in UI
- Verify read permissions on source
- Verify write permissions on target

## See Also

- [Connect Data Sources](https://docs.synthesized.io/tdk/latest/user_guide/010_get_started/datasources)
- [JDBC URL Examples](https://docs.synthesized.io/tdk/latest/user_guide/070_integrations/databases/)
- [Secret Managers](https://docs.synthesized.io/tdk/latest/user_guide/070_integrations/secret_management/secret_managers)
