H2 Database Spring Boot - How to connect and configure an in-memory H2 database in Spring Boot

Sdílet
Vložit
  • čas přidán 21. 09. 2022
  • In this tutorial, you will learn everything you need to know to connect and configure an in-memory H2 database in Spring Boot. I will also walk you through what you need to look out for if you are using Spring Security in your application.
    🔗Resources & Links mentioned in this video:
    Github Repository: github.com/danvega/h2-demo
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/danvega
    LinkedIn: / danvega
    Newsletter: www.danvega/dev/newsletter
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️
  • Věda a technologie

Komentáře • 42

  • @zelalemgizachew5563
    @zelalemgizachew5563 Před 2 měsíci +1

    Sacrified some mins to see this video and saved a lot of debugging hours. Thanks for the content.

  • @maxjustmax521
    @maxjustmax521 Před rokem +4

    I have no idea why do you have only 17K subs ... are people blind! I'm glad I found your channel.

  • @sharine8512
    @sharine8512 Před rokem +3

    I haven't even finished watching it and I can already say: Beautiful video! I've seen others (channels) very good ones, but this one is sensational. It explains exactly what is happening and why. This is giving me unprecedented autonomy, which I would take a good amount of practice and reading time to achieve. Thank you!🤩

  • @fabricio.entringer
    @fabricio.entringer Před rokem +1

    No doubts! The greatest video about this topic. Simple and straight to the point. 🙂 Congratulations and thanks for sharing it.

  • @MUSLIMWORLD2
    @MUSLIMWORLD2 Před rokem +2

    Amazing video❤ was struggling for two days then found this master piece.

  • @Burborted
    @Burborted Před 8 měsíci +1

    God... I haven't seen anything better, sir. Thank you for sharing your expertise.

  • @berkcr3769
    @berkcr3769 Před rokem

    oh man, thank you im intern and im studying for this on 4 days. finally i do that thanks to you

  • @debashishbhattacharjee8188

    Thanks for sharing such crisps videos.

  • @caginbektas
    @caginbektas Před rokem +1

    I must say thank you for all your effort Dan. This is a very clear and effective video

    • @DanVega
      @DanVega  Před rokem

      I'm glad you found it useful.

  • @abhishekomprakash4074
    @abhishekomprakash4074 Před 4 měsíci

    Thank you for this video. So much valuable information packed in 1 video. Concisely presented. 💯

  • @songbaiyin7830
    @songbaiyin7830 Před rokem

    Wow, this clears my doubts why you configure the data source that way in your previous tutorials. ❤

    • @songbaiyin7830
      @songbaiyin7830 Před rokem

      Learned lots of hows and WHYs along the journey, esp. the spring security part. 😘

  • @coddude3284
    @coddude3284 Před rokem

    your work is professional !

  • @Alexander-vov
    @Alexander-vov Před rokem

    Thanks for the video, it's a really helpful tutorial

  • @andreaang9448
    @andreaang9448 Před 9 měsíci

    Thanks, this was really clear and helpful for an exercise im doing :)

  • @berkcr3769
    @berkcr3769 Před rokem

    i love this video!

  • @magicianam1563
    @magicianam1563 Před rokem

    Good work, i'm new to spring & this is better than paid courses.

    • @DanVega
      @DanVega  Před rokem +1

      This made my day! Thank you so much 🤩

  • @prabhjotsingh9597
    @prabhjotsingh9597 Před rokem

    love the background

  • @PrashantRanjan1212
    @PrashantRanjan1212 Před rokem +1

    Hey Dan,
    Thanks for your really helpful videos. It would be really nice if you make a video on how to configure databases like Oracle, MySQL or MongoDB etc any one will work.
    Thanks

    • @DanVega
      @DanVega  Před rokem

      Thank you for the suggestion. I am trying something new to keep track of content suggestions like this one and I have added it to a repo.
      github.com/danvega/office-hours/discussions/24

  • @lucianoortizsilva
    @lucianoortizsilva Před rokem

    👏👏👏

  • @securethebag1613
    @securethebag1613 Před 6 měsíci +1

    is it possible to use hikari with an in memory database like h2 just to test the pooling?

  • @alexandern9266
    @alexandern9266 Před 9 měsíci

    Hi Dan,
    As I can see in SB configs EmbeddedDatabase implements shutdown method (which sends SHUTDOWN command to the DB) and SB registres that as destroy method when no Hikari is used.
    But if we use Hikari+H2 Hikari knows nothing about whether it is an Embedded datasource or not.
    If we use memory-based H2 I suppose it is not a problem.
    But what about file-based H2?
    What do you think is it safe to use file-based H2 with Hikari? Will it close the file properly?

  • @kacpersyrnik9853
    @kacpersyrnik9853 Před rokem

    Why this h2 console configuraton is not working with mvcMatchers?
    MvcMatcher as I understand is better version of antMatcher because it matches not only for example /demo but also /demo/ and /demo.html
    In My project
    mvcMatchers("/h2-console/**) is not working but if i have the antMatchers("/h2-console/**) as you, everything is fine, but why?

  • @alfonsovargas8578
    @alfonsovargas8578 Před rokem

    How I can create a repository using sql raw in H2 DB?

  • @hassanmohamed-iz2un
    @hassanmohamed-iz2un Před 9 měsíci

    how does spring repository know about the presence of H2 table

  • @ameensalem673
    @ameensalem673 Před rokem +1

    Hi, thank you for this tutorial!!
    i tried to follow when i do new Book(null, "str") i have error that id connot be null
    if i pass an id i have this error : Caused by: java.lang.IllegalArgumentException: After saving the identifier must not be null

    • @DanVega
      @DanVega  Před rokem

      This sounds like a schema issue. Are you auto generating an id in your schema?

    • @ameensalem673
      @ameensalem673 Před rokem

      @@DanVega this my schema :
      CREATE TABLE IF NOT EXISTS client (
      id INTEGER AUTO_INCREMENT,
      info BLOB
      );

    • @ameensalem673
      @ameensalem673 Před rokem

      and this is my client record : public record Client(@Id Integer id, String info) { }

    • @ameensalem673
      @ameensalem673 Před rokem +1

      @@DanVega Thank you, i figured it out, the @Id was not imported from the right package

    • @ameensalem673
      @ameensalem673 Před rokem

      can we use a string as the id of h2 table ?
      i have this error when i try to insert on the table with the id is a string column : Caused by: java.lang.IllegalArgumentException: After saving the identifier must not be null

  • @jamesrooney931
    @jamesrooney931 Před rokem

    Hi Dan - I'm using Spring Boot 3 (Spring Security 6) and I can't access the H2 console. With Spring Security 6 there is no antMatchers or mvcMatchers only requestMatchers which don't allow us the access the console - I have this line auth.requestMatchers("/h2-console/**").permitAll(). Is there a workaround to allow access?

  • @mohammedabraruddin9779
    @mohammedabraruddin9779 Před rokem +1

    love your tutorials but cannot follow as you are using white theme because its difficult for me to work at the white screen, i request you to use dark theme if possible

    • @DanVega
      @DanVega  Před rokem +2

      I get if dark theme is your personal preference (It's mine too) but I am not sure I understand why you can't follow along? Light themes are just better for tutorials and presentations and are easier for people to follow along with.

    • @mohammedabraruddin9779
      @mohammedabraruddin9779 Před rokem +1

      @@DanVega i got a eye diesease because of which i can't see properly on white screen but anyways thanks for the reply

  • @dovydasbalciunas5002
    @dovydasbalciunas5002 Před rokem

    Wtf is the record class?

    • @DanVega
      @DanVega  Před rokem

      Record type is new to Java which is available in Java 16+
      docs.oracle.com/en/java/javase/14/language/records.html