CRUD operations


Thursday, October 26, 2023 Difficulty: Intermediate

Objective

Create a Java program that allows you to perform CRUD operations from SQLite, the program must have the following menu:

  • 1. Add
  • 2. Show
  • 3. Edit
  • 4. Delete
  • 5. Exit

First prepare a SQLite version 3 database of people with a person table using the input''s SQL query. Then create the CRUD operations (add, view, edit, and delete).

Add

Ask the user for a name and age and insert the data into the database.

Show

Show all the people saved in the database.

Edit

Request the person''s code from the user and, if it exists, request the new name and age to modify the data in the database.

Delete

Request the person''s code from the user and if it exists, delete the person from the database.

Exit

End the program.

You don''t have to worry about the person''s code as it is auto-incremental.

Input

create table if not exists person
(
   cod integer primary key autoincrement,
   name varchar(20),
   age int
)

Output


                    

Solution

Click here to view the exercise solution

Share it

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

Copied

The code has been successfully copied to the clipboard.

More Exercises

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

1

Create database and tables

Create a Java program that creates a version 3 SQLite database with two tables (Person and Teacher).

2

Create in memory database

Create a Java program that creates a SQLite version 3 in memory database with two tables (Person and Teacher).

3

CRUD operations

Create a Java program that allows you to perform CRUD operations from SQLite, the program must have the following menu.

Databases

Practice with exercises in Java to manage databases. Learn how to perform CRUD actions on SQLite databases.

Practice exercises

Keep learning

C# Programming Course

Free programming course with practical exercises and solutions in C#. Start learning right now!

Exercises C# App

Take your Exercises C# lessons everywhere with our Android app. Download it now from Google Play