Java Spring Boot - JPA - Hibernate - H2 - Database Initialization using data.sql and schema.sql

Поділитися
Вставка
  • Опубліковано 4 гру 2024

КОМЕНТАРІ • 23

  • @ravinders9221
    @ravinders9221 3 роки тому +1

    hey thanks man, i did multiple projects with h2 integration after 6 months gap I forgot what I have done, wasted 2 hrs issue with inserting data. thanks man you saved my life.

    • @CodeForgeYT
      @CodeForgeYT  3 роки тому

      I am glad that video helped you! Keep Coding!

  • @carsmercholdjdm680
    @carsmercholdjdm680 4 роки тому +1

    Thank you! Very helpful! My only regret is I have not found your channel sooner

  • @arshiakaul7863
    @arshiakaul7863 3 роки тому +3

    Thanks a lot, man! It was really helpful.

  • @gazizmalibekov2234
    @gazizmalibekov2234 4 роки тому +1

    thanks for video! helped me with property "spring.datasource.data" to validate data.sql

    • @CodeForgeYT
      @CodeForgeYT  4 роки тому

      Great to hear that! You are welcome!

  • @arturorodriguez3110
    @arturorodriguez3110 2 роки тому +1

    very good video! mega helpful

  • @adityag974
    @adityag974 6 місяців тому

    If we have 2 schema how can we set the schema and data?

  • @sujithg5873
    @sujithg5873 3 роки тому +1

    Bro one doubt no need to set spring.datasource.initializationmode?

    • @CodeForgeYT
      @CodeForgeYT  3 роки тому +1

      Depends, by default it is set to embedded.

    • @sujithg5873
      @sujithg5873 3 роки тому +1

      @@CodeForgeYT Thanks

  • @programacaoja9679
    @programacaoja9679 3 роки тому +1

    what is the difference between data.sql and import.sql?

    • @CodeForgeYT
      @CodeForgeYT  3 роки тому +2

      Hey! data.sql can be used for inserting data to your database, schema must be already created. In case when you don't want to use default schema creation mechanism, you can create your own schema using schema.sql. Import.sql is specific for hibernate implementation and allows to load sql scripts. First two are spring specific and the last one is hibernate specific.

  • @jonathandipita8994
    @jonathandipita8994 3 роки тому +1

    i followed all the steps but my schema.sql file still not executed. could you help me please
    ?

    • @CodeForgeYT
      @CodeForgeYT  3 роки тому

      Hi! Check if it is in correct location, otherwise spring will be not able to find it.

    • @cscs2539
      @cscs2539 3 роки тому

      @@CodeForgeYT I am facing same issue and file is at right location.

    • @cscs2539
      @cscs2539 3 роки тому

      I am facing same issue and file is at right location.

    • @cscs2539
      @cscs2539 3 роки тому +1

      resolved it , jdbc url was wrong so had to remove DB_CLOSE_DELAY=-1 and it worked

    • @wantedlepota9960
      @wantedlepota9960 Рік тому +1

      update the classpath to spring.sql.init.schema-locations=classpath:db/schema.sql

  • @xThexMasterxProx
    @xThexMasterxProx 2 роки тому

    can you import from a CSV using data.sql ? If so, how do I indicate the CSV path?
    Will this work?
    COPY table_schema.table FROM '~/src/main/resources/database/csv/table.csv' WITH (FORMAT csv);