Share:- Whatsapp Facebook Facebook

------------------------------------- Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

0 votes
21 views
How do we connect an external database like MSSQL or oracle?
in Spring Boot by

1 Answer

0 votes
In spring boot connect with external database like mysql or oracel follow the following steps:-

Step 1:- The first step to connect the database like Oracle or MySql is adding the dependency for your database connector into pom.xml.

Add dependency for mqsql connector to pom.xml
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

Step 2:- The next step is remove H2 Dependency from pom.xml
<!--
<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>test</scope>
</dependency>
-->

Step 3:- Includes the schema and table to establish your database.

Step 4:- The next step is configuring of the database by using Configure application.properties to connect to your database.

application.properties:-
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/test_example
spring.datasource.username=root
spring.datasource.password=YOUR_PASSWORD

Step 5:- And the last step is to restart your application and now your connection is ready to use.
by (2.8k points)
...