Giter VIP home page Giter VIP logo

rest-spring-db's Introduction

rest-spring-db

To run the system and see the output we need to follow the following steps:

Server (RestSpringServer):


  1. We have to create a database called "userrest" then run the queries from userrest.sql file at MySql/MariaDb server
  2. Change following parameter according to your set-up at the database.properties file: db.username=root db.password=root db.url=jdbc:mysql://localhost:3306/userrest
  3. Run the server app(RestSpringServer) as "Run on server" at eclipse (I am using Tomcat server)
  4. You can hit the following url at browser : http://localhost:8080/SpringRestServer/service/user/1
    -- (it only works if you are running at port 8080. If your server port is different than 8080, you have to try with that)

This will provide the user info with id 1.

Client (RestSpringClient):


To test with the client application, you must run the server app first like mentioned above because from the client app we are calling the available webservices from the server. Server is connected to the database server. So, as soon as we call a service URI, server app will try to connect to the database and response with data if find any.

  1. Run the client app(RestSpringClient) as "Run on server" at eclipse
  2. Hit
    a. http://localhost:8080/RestSpringClient/getuser/1 to get a particular user(e.g. here 1 means user #1), internally calls rest service http://localhost:8080/SpringRestServer/service/user/{id}

Response: Get particular user service result (Printed at the console): <200,userName=S Dada, userId=1, age=26, salary=100000.0, address=1200 St Laurent Blvd,[Content-Type:"application/json", Transfer-Encoding:"chunked", Date:"Mon, 20 Apr 2020 03:50:07 GMT", Keep-Alive:"timeout=20", Connection:"keep-alive"]>

Client User Interface (UI):

For doing the CRUD operations, new UIs have been added (show all the users, add new user, edit user and delete a user).

  1. Show all users:
    URL: http://localhost:8080/RestSpringClient/getuserlist This will call the webservie from the server app and URI to fetch all the users, URI is: http://localhost:8080/SpringRestServer/service/user/

Client UI:

  1. Add a new user:
    URL: http://localhost:8080/RestSpringClient/createuser This will call the webservie from the server app and URI to add a new user, URI is: http://localhost:8080/SpringRestServer/service/user/create . New user data has been included in the request body (POST Request).

Client UI:

  1. Edit a user:
    URL: http://localhost:8080/RestSpringClient/updateuser/1 (Click the edit button from the "action" column of the user table, in this case
    first user was clicked to edit) This will call the webservie from the server app and URI to edit and update a user, URI: http://localhost:8080/SpringRestServer/service/user/update/ . Update user data has been included in the request body (POST Request). Server will internally perform a PUT request to update the user.

Client UI:

  1. Delete a user:
    Click the delete button from the "action" column of the user table, it will delete that user. This will call the webservie from the server app and URI to delete a user, URI: http://localhost:8080/SpringRestServer/service/user/delete/{id}". Here id is the id of the user we are deleting.

Further Improvement areas:

  1. Add custom validation
  2. Add logging (Log4j)
  3. Organize code and make everything configurable

rest-spring-db's People

Contributors

md-mamunabdulkayum avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

banglae-ss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.