Spring Boot: SQL
Working with SQL and Databases in Spring Boot
Debugging Help
When working with SQL-based databases in Spring Boot, it is helpful to put the following line in your application.properties
:
logging.level.org.hibernate.SQL=debug
This will output the SQL statements to the log so that you can see what is going on. This is particularly useful when the various middleware layers are doing the SQL statements for you, and for example, you aren’t even entirely sure what the names of the SQL tables are.
Initial Values in Database
You can seed your database with some initial values. This can be helpful especially during development and debugging phases.
The file data.sql
can be placed in src/main/resources
and has a syntax like this:
INSERT INTO course_offering (course,quarter,instructor) VALUES ('CMPSC 56','F19','Conrad');
INSERT INTO tutor (fname,lname,email) VALUES ('Scott','Chow','scottpchow@ucsb.edu');
Related topics:
- Spring Boot: —A Java web application framework
- Spring Boot: Actuator—Checking the endpoint mappings, health or other info about your Spring Boot app
- Spring Boot: Application Properties—Defining the application.properties
- Spring Boot: ControllerAdvice—A place to factor out common ExceptionHandler, ModelAttribute and InitBinder code across multiple controllers
- Spring Boot: CSV—Downloading and Uploading CSV files with Spring Boot
- Spring Boot: Database Migrations—When you need to make a change to your database schema for an app in progress
- Spring Boot: Heroku—Tips for running with Spring Boot applications on Heroku
- Spring Boot: Logging—How to write information to the log in Spring Boot
- Spring Boot: OAuth—How to implement OAuth for authentication in Spring Boot
- Spring Boot: POST and CSRF—If you get 403 forbidden messages when using POST
- Spring Boot: Postgres—Using Spring Boot with Postgres
- Spring Boot: RestTemplate—When you need to access other APIs from the backend of your Spring Boot Application
- Spring Boot: Secrets—Ways of keepings database credentials and OAuth client secrets out of Github
- Spring Boot: Security—Authentication, Authorization and other Security issues
- Spring Boot: Sessions—How to make the stateless HTTP protocol stateful
- Spring Boot: SQL—Working with SQL and Databases in Spring Boot
- Spring Boot: VS Code—Suggested VS Code extensions for working with Spring Boot