From the course: Spring: Spring Batch
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Writing to a database with named parameters
From the course: Spring: Spring Batch
Writing to a database with named parameters
- [Instructor] When using the JDBC batch item writer we have the option to to use springs JDBC template, which uses name parameters to map values to the sequel statement. Named parameters help prevent issues that pop up with ordinal values in prepared statements. So it's a much preferred approach. Let's make the switch over to the name parameters, which is a much simpler approach to writing information through our item writers to a data store. We'll continue to use the same JDBC batch item writer, however, we need to modify the sequel statement that's being used in order to use name parameters. So, we're going to replace these traditional question marks used in a prepared statement with a named parameter. And the format for that is going to be colon and then the name of your parameter. Now in order for this to work we need to match the names of the fields found within our order pojo. So, we'll go in and swap out each of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.