Database Config For JPA

 Database Config For JPA

spring.application.name=SpringMVC

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:ORCL

spring.datasource.username=mvc

spring.datasource.password=mvc

spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

spring.jpa.open-in-view=false

spring.jpa.show-sql= true

spring.jpa.hibernate.ddl-auto=update



Explanation:


1. spring.application.name=SpringMVC

Explanation: This property sets the name of your application. Here, the application name is set to
"SpringMVC."
Usage: The application name can be useful for logging or monitoring purposes, allowing you to
identify logs or other information specific to this application.

2. spring.datasource.url=jdbc:oracle:thin:@localhost:1521:ORCL

Explanation: This property defines the URL of the database.
  • jdbc:oracle:thin: specifies the Oracle database protocol.
  • @localhost:1521 indicates the database is running on the local machine on port 1521.
  • ORCL is the service name of your database, identify which specific database to connect.

3. spring.datasource.username=mvc

Explanation: This property defines the username for connecting to the database.
Usage: This username is used for authenticating access to the database, allowing your application
to log in with specific privileges.


4. spring.datasource.password=mvc

Explanation: This property defines the password for the database user.
Usage: This password, along with the username, is used to authenticate access to the database.

5. spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

Explanation: This property defines the database driver class. Here, oracle.jdbc.OracleDriver
is the driver used to connect to an Oracle database.
Usage: Specifying this driver helps Spring Boot know that it needs to connect to an Oracle
database.

6. spring.jpa.open-in-view=false

Explanation: This property controls whether the JPA session (or Entity Manager) stays open
throughout the view layer (during rendering of a web view). Setting it to false closes the JPA
session at the end of each request.
Usage: This can help improve performance but may cause issues with Lazy Loading. Lazy Loading
only loads data when it’s actually needed, and if the session is closed, you might get errors
if you try to access data that hasn’t been loaded yet.

7. spring.jpa.show-sql=true

Explanation: When this property is set to true, the SQL queries generated by Hibernate are shown
in the logs.
Usage: Seeing SQL queries in the logs can be very helpful during development and debugging,
allowing you to understand which queries are being executed.

8. spring.jpa.hibernate.ddl-auto=update

 Explanation: This property tells Hibernate how to handle the databasestructure (tables and
columns).
update means Hibernate will update the existing database structure without deleting any data.
New tables or columns will be added if needed.
Usage: Setting this to update is often useful in development, as it lets you modify the database
schema automatically without needing to manually change the database structure.


Comments