Search code examples
htmlspring-bootspring-data-jpadb2thymeleaf

Spring Boot app configuration with DB2 database


Could someone with experience please share recommendations on configuring a db2 database with a Spring Boot App?

Creating a Spring Boot app that will access a db2 table using JpaRepository to render results from query in an HTML view using Thymeleaf.

Looking for a general explanation on how to configure a Spring Boot App that will access a db2 table using Spring Data Jpa. Specifically, what would I need in my build.gradle and application.properties to make this happen?


Solution

  • i think this may help you i used it in simple poc

    
    # ===============================
    # = DATA SOURCE
    # ===============================
    # Set here configurations for the database connection
    spring.datasource.url=jdbc:db2://localhost:50000/EXAMPLE
    spring.datasource.username=db2inst1
    spring.datasource.password=db2inst1-pwd
    spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver
    # Keep the connection alive if idle for a long time (needed in production)
    spring.datasource.testWhileIdle=true
    spring.datasource.validationQuery=SELECT 1
    # ===============================
    # = JPA / HIBERNATE
    # ===============================
    # Show or not log for each sql query
    spring.jpa.show-sql=true
    # Hibernate ddl auto (create, create-drop, update): with "create-drop" the database
    # schema will be automatically created afresh for every start of application
    spring.jpa.hibernate.ddl-auto=create-drop
    
    

    and you can read this article may help you here and here and i recommend u the second one