Git Product home page Git Product logo

import-data-using-apache-commons-csv's Introduction

Import data into MySQL using Apache Commons CSV

Project used for importing csv file into MySQL database using Apache Commons CSV.

Description

Spring Boot provides some properties with which we can add the exception message, exception class, or even a stack trace as part of the response payload:

server.error.include-message=always
server.error.include-binding-errors=always
server.error.include-stacktrace=on_param
server.error.include-exception=false

Using these Spring Boot server properties in our application.properties we can alter the error response to some extent.

Note that we’ve set the property include-stacktracee to on_trace_param which means that only if we include the trace param in the URL (?trace=true), we’ll get a stack trace in the response payload:

We might want to keep the value of include-stacktrace flag to never, at least in production, as it might reveal the internal workings of our application.

Getting Started

Dependencies

  • Spring Web
  • Spring Boot
  • Spring Data JPA
  • Apache Commons CSV
  • MySQL Database

Installing

  • Run the following command in the project root for creating MySQL database in Docker
docker-compose up -d

To set container name as mysql instead of the folder name where docker-compose.yml file is located, use the following command:

docker-compose -f docker-compose.yml -p "mysql" up

  • Database connection url:
jdbc:mysql://localhost:3306/employee-db

API Endpoints

All URIs are relative to http://localhost:8080/api/v1

Class Method HTTP request Description
EmployeeController importFile POST /employees/import Import list of employees file
EmployeeController findByEmail GET /employees/{email} Get employee by email
EmployeeController findAll GET /employees Get all employees
EmployeeController deleteAll DELETE /employees Delete all employees

Documentation

Apache Commons CSV User Guide
Hibernate ORM 5.6.10.Final User Guide
Hibernate Natural Ids with @NaturalId
The best way to map a @NaturalId business key with JPA and Hibernate
How to Use Hibernate Natural IDs in Spring Boot

Authors

Murat Yıldız

Version History

License

...

Acknowledgements

...

import-data-using-apache-commons-csv's People

Contributors

yildizmy avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.