ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

Spring JDBC Template Tutorial: Learn to build a full CRUD application in Spring Boot

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • In this tutorial, you will learn how to list, create, read, update, and delete records from a database in a Spring Boot application using JDBC Template. You will learn how to create a project from scratch, connect to a database, and the various methods in the JDBC Template that allow you to create a full CRUD application.
    0:00 Introduction
    3:15 Create a new Spring Boot Application
    6:00 Create Course Model
    8:30 Connect to H2 database
    13:10 Create DAO Interface
    15:25 Create Course DAO implementation
    18:10 List All Courses
    25:35 Create a new course
    29:50 Read a single course from the database
    33:40 Update Course
    35:35 Delete Course
    🔗Resources & Links mentioned in this video:
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/danvega
    Instagram: / thedanvega
    LinkedIn: / danvega
    Coffee & Code: www.danvega/dev/newsletter
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

ความคิดเห็น • 53

  • @guitarDad100
    @guitarDad100 2 ปีที่แล้ว

    Very nice work. I have worked with Spring Boot JDBC but i like you CRUD DAO set up. Much cleaner. Thanks for posting this video.

  • @MsPolish89
    @MsPolish89 3 ปีที่แล้ว +4

    Thank you very much, this tutorial helped me a lot to undertand the basics of jdbc template.

    • @DanVega
      @DanVega  3 ปีที่แล้ว +1

      You are welcome!

  • @michael-john4954
    @michael-john4954 11 หลายเดือนก่อน +1

    Great video Dan!

  • @devoiddude
    @devoiddude 2 ปีที่แล้ว

    Thank you so much for this video.

  • @BrunoFPcovers
    @BrunoFPcovers 3 ปีที่แล้ว

    Thank you Dan!

  • @vivekgupta309
    @vivekgupta309 2 ปีที่แล้ว

    very well explained. I appreciate it.

  • @fabrizziocordova5250
    @fabrizziocordova5250 ปีที่แล้ว

    Very useful and incredibly informative

  • @gasparcalix2095
    @gasparcalix2095 2 ปีที่แล้ว

    GRate work!!!!
    it help me alot!

  • @Deepakguptasky
    @Deepakguptasky 2 ปีที่แล้ว

    Thank you Dan for this good work !

    • @DanVega
      @DanVega  2 ปีที่แล้ว

      Thank you for watching!

  • @artetl
    @artetl 6 หลายเดือนก่อน

    Thank you. That’s useful!)

  • @ahmadraza7049
    @ahmadraza7049 2 ปีที่แล้ว

    very good explanation really loved it
    🙂

  • @praveens2272
    @praveens2272 ปีที่แล้ว +1

    If you are working with database first approach and you need to write some complex queries with multiple table joins then Spring JDBC is life saver. No need to under estimate it. Spring data jpa is a good choice if you are developing brand new microsercive with code first approach and less complex database schema.

  • @MewchildyT
    @MewchildyT 3 ปีที่แล้ว +1

    Thank you, very great video!

    • @DanVega
      @DanVega  3 ปีที่แล้ว

      You are welcome!

  • @kmekky3870
    @kmekky3870 2 ปีที่แล้ว +1

    Thanks a million Dan, we would love a follow up to this video with Rest API if you have the time.

  • @gyorgyszabo3607
    @gyorgyszabo3607 3 ปีที่แล้ว

    Thank you!

  • @stakhovskiy
    @stakhovskiy 3 ปีที่แล้ว

    Thanks a lot!

  • @yarik83men51
    @yarik83men51 2 ปีที่แล้ว

    Super, you save me a time

  • @Sunil_Veeramuthu
    @Sunil_Veeramuthu 11 หลายเดือนก่อน +2

    Thanks, Dan! Actually, the JDBC API would have sufficed; you don’t need the Spring Data JDBC from the starter page as you’re not using any of the Spring Data features in this tutorial.
    Honestly, I like the raw power of SQL, and using the JDBC API allows me to carefully think about the database interactions and have better control over the queries. Spring Data is enough magic already; JPA on top of it is a no-no for me.

  • @btryx9378
    @btryx9378 2 ปีที่แล้ว +1

    Hi, how comes that at 24:11 we put the DAO interface in the constructor instead of the class that implements it (CourseJDBCDao)? I don't really get that part. Sorry if its a dumb question.

  • @michelchaghoury9629
    @michelchaghoury9629 2 ปีที่แล้ว

    Great Vid i have a Question @Dan Vega
    if i am using Spring Data JPA and want to map a Query Result using @Query to a non entity (for example a record used as a DTO) how can i do it ?

  • @georgievvladimir
    @georgievvladimir ปีที่แล้ว +1

    Great tutorial! BTW the only think missing here is an example of getting one course that doesn't exists.

  • @pryflack3646
    @pryflack3646 2 ปีที่แล้ว +3

    Nicely done :)
    It would have been nice to briefly discuss the pros and cons of this tech against other similar solutions such as JDBI, mybatis (and maybe more?)
    I was also slightly confused why you didn’t use the @Repository annotation which could have been a little more descriptive?

  • @jeevanthalluri2200
    @jeevanthalluri2200 2 ปีที่แล้ว

    how to call stored procedure using jdbc template in spring boot frame work ?
    with in,out and inout parameters ? Hope i will receive the response

  • @xiaoyuli4703
    @xiaoyuli4703 3 ปีที่แล้ว +1

    Hi there, Could you please explain for me that, when you create a constructor within the CoursePlatformApplication class, and the constructor accepted a DAO as a parameter, but how is DAO parameter got passed to the constructor, I saw you use the "dao" directly in the main function.
    Thank you.

    • @manaslovesbirds
      @manaslovesbirds 3 ปีที่แล้ว

      through Spring's Constructor dependency injection

  • @siddharthasharma5644
    @siddharthasharma5644 3 ปีที่แล้ว

    Can you show me an example how to create JavaFX project with Spring Boot? No tutorial I found of JavaFX + Spring Boot yet.
    I m from India and your new learner...I m waiting for that one. your JDBC Template is very easy to understand .

  • @krishnasurisetty1362
    @krishnasurisetty1362 2 ปีที่แล้ว

    If we are using
    public CourseJdbcDaoImpl(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
    }
    how is the jdbc template being initialized, It needs a DataSource object in it's constructor. Please let me know how this works. Does'nt the existing code gives a null reference

  • @DevMERNia
    @DevMERNia 2 ปีที่แล้ว

    How do you model relations that have inheritance?

  • @sachinmankotia2291
    @sachinmankotia2291 2 ปีที่แล้ว +1

    Thanks for this video :)
    One question, Do you have created video to work with multiple linked tables (example Student and Course tables having 1:M mapping) with Spring jdbc?
    With Spring JPA, its simple as we can define all mapping in entity class, But I want to implement that using Spring data JDBC.

    • @DanVega
      @DanVega  ปีที่แล้ว

      I don't have anything yet but I will get that on the backlog. Thank you for the suggestion. In the meantime did you have a chance to look through our documentation?
      docs.spring.io/spring-data/jdbc/docs/current/reference/html/

  • @ShaileshDagar
    @ShaileshDagar ปีที่แล้ว +2

    I have a Question. Around 16:55 you said that we need only one instance of "jdbctemplate", so why not make it 'static'?

    • @DanVega
      @DanVega  ปีที่แล้ว +1

      If the variable was static it would only be accessible from static methods. By declaring the variable private we are ensuring its only available in our class and Spring will handle autowiring the instance in for us. The JdbcTemplate is a singleton scope so there will only be a single instance in the application.

    • @ShaileshDagar
      @ShaileshDagar ปีที่แล้ว

      Thanks for answering that. Looks like I need some reading on Beans Scope.

  • @dinobulja
    @dinobulja 2 ปีที่แล้ว

    Why annotating class that talks to DB as @Component. Isnt @Repository more appropriate? Thank you

  • @mr.RAND5584
    @mr.RAND5584 6 หลายเดือนก่อน

    Optional.empty has console display unexpected end of JSON input at Json.parse(.....

  • @wesleyjackson7524
    @wesleyjackson7524 3 ปีที่แล้ว +3

    hi dan!, did you made the tutorial where you build the Rest APItalks with the DAO?

    • @caspianrobert7327
      @caspianrobert7327 3 ปีที่แล้ว

      You prolly dont give a damn but does any of you know a method to get back into an instagram account?
      I stupidly forgot my account password. I would appreciate any assistance you can offer me.

    • @elonjackson5121
      @elonjackson5121 3 ปีที่แล้ว

      @Caspian Robert Instablaster :)

    • @caspianrobert7327
      @caspianrobert7327 3 ปีที่แล้ว

      @Elon Jackson Thanks so much for your reply. I got to the site thru google and im waiting for the hacking stuff now.
      I see it takes quite some time so I will get back to you later when my account password hopefully is recovered.

  • @sunilanthony17
    @sunilanthony17 3 ปีที่แล้ว +1

    I need to use a database that only uses store procedures to perform CRUD operations which lands me here...Spring JPA/Hibernate is real clunky when it comes to store procedures. I also notice that query and queryForObject are deprecated. Can you show the replacement?

    • @DanVega
      @DanVega  3 ปีที่แล้ว +1

      query will work and the last argument is any number of args
      jdbcTemplate.query(sql,rowMapper,id);

    • @sunilanthony17
      @sunilanthony17 3 ปีที่แล้ว

      @@DanVega Yes, it will work if you suppress the deprecation warning but I was looking for what they are replacing it with if they are deprecating "query".

  • @ronyjohn376
    @ronyjohn376 2 ปีที่แล้ว

    Is it worth it to upgrade from a Plain JDBC application to Spring JDBC? Is there a reason why you wouldn't suggest that approach?

  • @jeevanthalluri2200
    @jeevanthalluri2200 2 ปีที่แล้ว +1

    how to configure multiple data sources in a single spring boot project

    • @DanVega
      @DanVega  ปีที่แล้ว

      Thanks for the suggestion. I will get that added to my backlog.

  • @darshanraut554
    @darshanraut554 2 ปีที่แล้ว +1

    Why not keep it simple and avoid use of templates :(

    • @pryflack3646
      @pryflack3646 2 ปีที่แล้ว

      Can you explain yourself more? I see what seems to be a nice abstraction here with, what seems to be, reduced boilerplate.
      What did you feel could be simpler?

  • @lastsaiyan9035
    @lastsaiyan9035 2 ปีที่แล้ว

    thanks a lot, trying to transition to a java role from node.js
    have a java interview coming up, this helps