#1
This guide shows how to build a Spring Boot CRUD application using SAP HANA Express as the database. Follow the steps directly and test it right away.

1. Create Spring Boot Project

Use Spring Initializr :
  • Project: Maven
  • Dependencies: Spring Web, Spring Data JPA

2. Add SAP HANA JDBC Driver

Download ngdbc.jar from SAP, then install manually into Maven local repo:
mvn install:install-file \
  -Dfile=ngdbc.jar \
  -DgroupId=com.sap.cloud.db.jdbc \
  -DartifactId=ngdbc \
  -Dversion=2.18.14 \
  -Dpackaging=jar
Add in pom.xml :
<dependency>
  <groupId>com.sap.cloud.db.jdbc</groupId>
  <artifactId>ngdbc</artifactId>
  <version>2.18.14</version>
</dependency>

3. Configure application.properties

spring.datasource.url=jdbc:sap://localhost:39015/?databaseName=HXE
spring.datasource.username=SYSTEM
spring.datasource.password=YourPassword
spring.datasource.driver-class-name=com.sap.db.jdbc.Driver

spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.HANARowStoreDialect 

4. Create Entity

import jakarta.persistence.*;

@Entity
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String email;

    // getters and setters
}

5. Create Repository

import org.springframework.data.jpa.repository.JpaRepository;

public interface UserRepository extends JpaRepository <User, Long> {
}

6. Create REST Controller

import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {
    private final UserRepository repo;

    public UserController(UserRepository repo) {
        this.repo = repo;
    }

    @PostMapping
    public User create(@RequestBody User user) {
        return repo.save(user);
    }

    @GetMapping
    public List<User> readAll() {
        return repo.findAll();
    }

    @GetMapping("/{id}")
    public User readOne(@PathVariable Long id) {
        return repo.findById(id).orElseThrow();
    }

    @PutMapping("/{id}")
    public User update(@PathVariable Long id, @RequestBody User user) {
        User existing = repo.findById(id).orElseThrow();
        existing.setName(user.getName());
        existing.setEmail(user.getEmail());
        return repo.save(existing);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        repo.deleteById(id);
    }
}

7. Run and Test

Start the app:
mvn spring-boot:run
Test endpoints using Postman or curl:
  • POST /users → create user
  • GET /users → list all
  • GET /users/{id} → get one
  • PUT /users/{id} → update
  • DELETE /users/{id} → delete

image quote pre code