Posts

Showing posts from January, 2018

#3 Passing Query Paramater In REST API

Image
Please go through series 1 and series 2 before starting this tutorial. In my last tutorials I have explained that how can we create simple hello world API and how can we access DB by using JDBCTemplate . JDBCTemplate is spring framework's library which make easy to access the DB. So now let me continue to the topic. Lets extends EmployeeDao to another method which will fetch Employee data based on email id passed. Please see the example below: Please note that I have added another method with email parameter. Now lets implement this method in interface implementation class ( named as EmployeeDaoImpl ): Now lets write REST api to access employee data with email passed. Write following method in your Controller class: We write another REST api names getemployee with request parameter email.  I have used  @RequestParam for parameter. You can make parameter as required OR optional . Now to access api you can call rest url as given below, by passin

#2 Simple Spring Rest Api with JDBC connection

Image
Before starting this tutorial, I am assuming that you guys have basic idea of Spring. If you don't have basic idea of simple Spring API then no worry :), I have written simple tutorial here to start with Spring Boot . This tutorial is next version of my first tutorial . In my first tutorial I explained that how can we make a simple REST api with Spring Boot .  So lets start with JDBC connection in some very simple steps: 1. Create DB schema and table I prefer MySqlWorkBench for this purpose ( you can use any way to create schema). For this tutorial I have named my db as test_db . This DB contains one Employee table with below schema: Table contains id, name and email of employee ( This is just for tutorial, You make table as per your requirement). Once you created table, Insert some dummy data for your REST api. Your api will be fetching this data and will return it as JSON. I have made some of dummy entries as below: 2. Add Maven depen

#1 My First Rest API With Spring Boot Freamwork

Image
I hope you must be familiar with Java . Spring is a Java framework which is used for Rest api development by using Java as language. If you want to have basic idea about spring then you can visit here . In this tutorial I will be focusing on simple rest api using Get method. Please follow steps below to create your first Rest api: 1. Create project schema: While creating project schema, we can simply create via eclipse by going file -> new -> Maven Project .  If we are using above method to create project schema then for Maven dependencies we will need to make entry in Pom.XML. To avoid that we can refer  start.spring.io . In this tutorial I will be creating project via this interface only. So lets avoid any more delay and start development in some very simple steps: Open website  start.spring.io  and enter group (package), Artifact (name). After this add all required dependencies. Initially we will required only Spring MVC dependency as in screenshot bel