This Maven project implements a REST API for managing "Alien" records. The API supports basic CRUD (Create, Read, Update, Delete) operations and is implemented using Jersey Quick Start.
The database for storing the Alien data is created using JDBC, and the API is tested using Postman.
com.srinivas.Restdemo.Alien: A Java class representing the Alien entity with fields like alienid, name, and points.
com.srinivas.Restdemo.AlienResource: This class contains the RESTful API methods to handle requests.
com.srinivas.Restdemo.AlienRepository: This class handles database operations using JDBC.
API Endpoints
-
Get All Aliens Path: /alienresource/getAliens
Method: GET
Description: Retrieves a list of all aliens in the database.
Produces: application/json, application/xml -
Get a Single Alien Path: /alienresource/getAlien/{id}
Method: GET
Description: Retrieves the details of an alien by its ID.
PathParam: id - The ID of the alien to retrieve.
Produces: application/json, application/xml -
Create a New Alien Path: /alienresource/createAlien
Method: POST
Description: Adds a new alien to the database.
Consumes: application/json, application/xml -
Update an Existing Alien Path: /alienresource/updateAlien
Method: PUT
Description: Updates an existing alien record. If the alien with the given ID doesn't exist, a new record is created.
Consumes: application/json, application/xml -
Delete an Alien Path: /alienresource/deleteAlien/{id}
Method: DELETE
Description: Deletes an alien from the database based on its ID.
PathParam: id - The ID of the alien to delete.
Consumes: application/json, application/xml
Database Name: restdb
Table Name: aliens
Columns:
id (INT): Primary key, unique identifier for each alien.
name (VARCHAR): Name of the alien.
points (INT): Points associated with the alien.
Java: The primary programming language used.
Maven: For managing project dependencies and building the project.
Jersey Quick Start: For implementing RESTful web services.
JDBC: For database connectivity.
MySQL: Database used to store the Alien records.
Apache Tomcat: Server used to deploy the REST API.
Postman: For testing the API endpoints.