Skip to content

kafleprakash96/jsontoblob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Application Setup

Overview

This document provides instructions on how to run the Spring Boot application, including details on configuring application.properties and .sql files. You will also find code snippets and a guide on using the POST API.

A database schema with table is required in database. I have ran the following query in mysql.

-- SQL schema for the article_blob database

CREATE DATABASE article_blob;

USE article_blob;

CREATE TABLE IF NOT EXISTS articles (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
content BLOB
);

Configuration Files

application.properties

To configure the Spring Boot application, use the following properties in your application.properties file:

Replace url with your schema url if you are using other than article_blob.

Replace with your username and password.

spring.datasource.url = jdbc:mysql://localhost:3306/article_blob
spring.datasource.username = root
spring.datasource.password = password

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.ddl-auto = update

Running the Spring Boot Application

To start the Spring Boot application, follow these steps:

Build and Run: Open your terminal, navigate to your project directory, and run the following command:

```bash
./mvnw spring-boot:run
```

This will start the application on localhost:8080.

Springboot Screenshot

*** POST REQUEST

Send a POST Request: Use Postman to send a POST request to http://localhost:8080/article/save.

This request will get all the json data into database.

key in json file is stored as column and their value are stored as row. title and author are stored as string(varchar) and content is stored as blob.

Sample Request Body: Use file article.json from assets folder

Postman Screenshot

Verify your database : See if the content is stored as blob

  select * from article;

Database Screenshot

*** GET REQUEST

Send a GET Request: Use Postman to send a GET request to http://localhost:8080/article/1.

This request get all the data from the database and converts into json.

Postman Screenshot

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages