AWS RDS with Spring Boot - A Step-By-Step Guide @ashokit

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to our Channel Ashok it in this video we will understand how to connect with AWS Cloud database by using spring boot application so first let's understand what is this Amazon RDS service RDS is your service in the AWS Cloud which is used to manage relational databases here if you want to communicate with a database first we need to set up the database software in our system we need to take care of that database we need to take care of database security we need to take care of database backup database update lot of things that we need to take care in order to maintain your database which is required for our application here instead of we are managing the database we can use AWS RDS service that is a managed service in the AWS Cloud by using that that service we can set up a relational database in the cloud Amazon RDS RDS stands for relational database service in the AWS here the advantage of going with this RDS is several Administration tasks like availability of the database scalability of the database security of the database performance of the database backup such kind of administrator activities will be taken care by aw s only you just need to set up a database in the AWS cloud and you need to connect to the database by using your application the remaining the management related Administration related tasks will be taken care by AWS Cloud that's why most of the projects in the companies most of the companies will prefer This Cloud databases because cloud provider will manage our database we will just use the database and we will pay rent for that this AWS cloud provid proving the database based on pay as you go service how much you use for that you need to pay the money for AWS Cloud so I'm going to show you a demo how to create a database in the AWS cloud and how to connect with the database by using our spring boot application all right so here I logged in into my AWS account I have selected the region as a Mumbai now here AWS RDS service is available you can search for that service in this account currently no databas is available let me click on create database here you can select what type of database you want to create relational databases like waracle MySQL postgress SQL Server several databases it is supporting as part of RDS service so I'm going for standard create database engines which are supporting by RDS Aurora my SQL Marb postgress Oracle SQL Server like that several relational databases are supported by RDS I'm selecting my SQL database engine now in this my SQL database engine here my SQL version is selected as 8.0.3 I'm keeping like that I'm not changing that version and I'm going here do you want this database for production purpose or de test purpose or free tire I'm using this for free tire I'm selecting this free tire here good now availability and durability settings database identifier name of the database so I'm not changing that identifier credentials you can change the username and password by default username is admin password you can select that password I'm selecting password right confirm the password let me choose the password and let me enter that password perfect so I have given password and confirm password instance configuration D T3 micro instance then come down connectivity default VPC it requires a network to create the database AWS will provide one default VPC for the network the default VPC selected by default and here you need to select Public Access yes we need to give the public access as yes because my application is running in my local machine my application should connect with the cloud database so public access the database should have a public access select this option as yes and Security Group if you have Security Group already in the AWS account you can choose the existing Security Group if you don't have the security group then you need to create the security group and you need to select that Security Group I have selected my by default it selected default Security Group which is available and I don't have any available to J preference so good go with password authentication it's configuration so here initial database name so in the in the my SQL we need to create a database by using Create database database name if you want to create some database by default you can give the name of the database here I'm giving the database name as coures database some courses database I'm giving as a name then simply click on create that's it yes You observe what are the options that I have selected standard create option I have selected my SQL database I have selected and free tire I have selected then I have selected password user name by default admin password I have given my own password then VPC by default default VPC only here I have changed public access to yes because we need to connect with the database from outside security group default only then in the additional configuration I have given the database name as C s database that's it yeah click on create database so when we click on create database it will take some time to create the database in the cloud database creation is in progress now you can see that database creation is in progress once this database is created we can see the database endpoint that means the username of the database and you can see credentials of the database here data creation is in progress your database might take few minutes to launch view credentials details when you click on this button it is giving the username of the database and it is giving password of the database this username and password one time downloadable guys so I'm going to take my database username as admin password ashoke 321 I can copy that password in our spring boot application data source properties will configure in application. yml so in the previous video I have shown you how to connect with my SQL database and how to perform crowd operations this project is developed in the previous video now here same application I'm using just I'm changing username and password username is admin and password is ashoke 321 earlier this application connected to my SQL database which is available in my machine that is Local Host now I want to connect with database available in AWS Cloud so still database creation is in progress let's click on the database identifier once this database is created successfully here it will display end point end point represents the URL of the database and port number for my SQL database default port number is30 6 only so we need to wait till this database creation got completed once the database status is created it is active then here we can see endpoint URL and we can see put number right and meanwhile we have selected One Security Group for this database right that Security Group will stop our request if you don't enable the particular protocol this database will be running on the protocol 1306 let's go to the security group and you need to enable the port number the port number of this mySQL database is3 06 right go to Security Group in that Security Group inbound rules concept will be available so edit the inbound rules in the inbound rules you need to enable a protocol right which protocol we need to enable so we need to add custom TCP the protocol as36 anywhere so we need to add that protocol and save that that means we are telling to this AWS Security Group to allow the request for that d306 protocol that is the meaning of that now still database creation is in progress let's wait still it is getting created instance database still the status is creating open the database and verify still endpoint URL is not generated we need to wait till the endpoint URL got generated right database status still creating yeah right guys now we can see that our database status is backing up now Here If You observe the endpoint URL got generated and the port number is also generated so endpoint nothing but the database host where the database is running and what is the port number it is using 30636 port number we have to enable in the security group inbound rule we have already done that process take this database host go to application. yml file instead of Local Host now I am going to to give the database host which is created in the AWS cloud36 port number I have given initial database name as courses database name I have given as courses and this is our driver class username password and database URL in the database URL earlier we have given Local Host to connect with our local database now our database is created in the AWS Cloud so I'm giving the Local Host as AWS RDS database endpoint perfect so with this we are good now once this database is created are we able to connect with the database or not how to verify that for that we can use my SQL workbench let me go for workbench and let me test database connection really the cloud database is working as expected or not once we take the confirmation then we will run the application and we will see that here I will create a new connection in this MySQL workbench new connection connection name AWS RDS MySQL and host name host name here it is displaying as endpoint take this endpoint name give it as a host Port number3 06 username is admin password ashoke 321 I have given click on okay now test connection check it yes successfully made the SQL connection that means by using this MySQL workbench we are able to connect with the database available in AWS Cloud if our connection is successfully here that means our application also can connect for that now let me connect to this and let me check database is created or not we have given the initial database name as courses so let me execute a command show databases I'm executing a command called show databases let me run this query yes so show databases see here I have executed it is giving the database name as a courses now use the database as database name use database name courses then show tables I want to display all the tables available in the database no tables available because it is a brand new database just now we have created now let's go to our boot application in the boot application we have repository we have entity class which is mapped to a data table and in the yml file we have given ddl auto update table will be created in our database good run the project before that let me do a MAV update update update the project force update okay once the project is updated successfully then let's run this project and see table is getting created in the database or not and we will insert one record also and we will test that good updat successful run as boot application spring boot application is getting started this spring boot application should connect with database available in the AWS Cloud because I have configured AWS RDS database properties in application. yml yeah guys see here our application is started in the console you can see that create create table query got executed so that means it connected with our database and it created table also in the database now let's go to workbench and let's check show tables earlier it has not given any result now execute show tables now you can see course details table got created in Cloud database then select a star from table name what is the table name course uncore details let's select this query and execute it in the table we don't have any records now my application is a rest API so let me send a request by using Postman and let me test record is inserting or not go to postman I want to send a post request so here I'm selecting the request type as post Local Host colon 8080 SLC course so in our application we are having one method in the rest controller that method is binded to post request it will take the course data in the request body as a that will insert the record into database table let us test this functionality Local Host colon 8 8/ course data I'm giving in the body as a Json click on send when we click on send here you can see on the console insert query got printed that means insert query is executed go to the database and check that select star from database yes one record got inserted we are able to communicate with a AWS Cloud database by using spring boot application what we have done for that we created a database in the AWS Cloud we have taken endpoint of the database and we have taken port number we enabled that port number in the security group3 06 is the default put number that credentials of the database we configured in application. yml username password and database host and database port and database name with this we are able to understand how to communicate with AWS Cloud database by using spring boot application got it thanks for watching this video please subscribe to our Channel and click on Bell icon for more updates thank you guys we'll see you in the next video
Info
Channel: Ashok IT
Views: 11,891
Rating: undefined out of 5
Keywords: ashok it, aws database, rds in aws, spring boot, how to connect with database using springboot, multiple databases using spring boot, aws tutorial, rds backup, aws rds tutorial for beginners, aws cloud, spring boot introduction, spring data jpa tutorial, spring boot microservices, spring security, spring boot crud operations with mysql, spring boot data jpa tutorial, ashokit, multiple databases connection using spring boot
Id: GSu1g9jvFhY
Channel Id: undefined
Length: 15min 49sec (949 seconds)
Published: Tue Dec 20 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.