Skip to content

A demo project to show usage of spring framework with scala language

Notifications You must be signed in to change notification settings

fatihcataltepe/gs-relational-data-access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

This is a demo application to show usage of spring framework with scala. It basically provides web interface to manipulate a mysql database.

Setup

Before running the application, there must be a customers table with three fields: id, first_name and last_name.

Run the following mysql script in a database editor (DataGrip etc.)

#drop if test db already exists
drop SCHEMA if EXISTS  test;

#create test db
create SCHEMA test;

#use test db
use test;

# create customers table
CREATE TABLE test.customers
(
    id INT PRIMARY KEY AUTO_INCREMENT,
    first_name VARCHAR(100) NOT NULL,
    last_name VARCHAR(100) NOT NULL
);

Configuration

In application.properties file update the database information: username, password

The default is as follows:

#disbale Spring banner
spring.main.banner-mode=off

# Loads SQL scripts? schema.sql and data.sql
#spring.datasource.initialize=true

spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test
spring.datasource.username=root
spring.datasource.password=12345
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

# HikariCP settings
# spring.datasource.hikari.*

#60 sec
spring.datasource.hikari.connection-timeout=60000
# max 5
spring.datasource.hikari.maximum-pool-size=5

Usage

After running the application, there will be 5 web services available. You can use Postman or curl to test them.

Web Services

1. [GET] /customers

  • Returns the list of all customers as json list

2. [GET] /customers/{id}

  • Returns the requested user as json object

3. [DELETE] /customers/{id}

  • Deletes the specified user if exists

4. [POST] /customers

  • Creates a new user and inserts it into database

Body:

{ "firstName":"hello", "lastName":"world" }

5. [PUT] /customers/{id}

  • Updates the specified user in the database

Body:

{ "firstName":"hello", "lastName":"universe" }

About

A demo project to show usage of spring framework with scala language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages