DATABASE for this project CREATE TABLE Question ( id SERIAL PRIMARY KEY, question_title TEXT NOT NULL, option1 TEXT NOT NULL, option2 TEXT NOT NULL, option3 TEXT NOT NULL, option4 TEXT NOT NULL, right_answer TEXT NOT NULL, difficulty_level TEXT NOT NULL, category TEXT NOT NULL ); INSERT INTO Question (question_title, option1, option2, option3, option4, right_answer, difficulty_level, category) VALUES ('What is a class in Java?', 'A function', 'An object', 'A data structure', 'A loop', 'An object', 'Easy', 'java'), ('What does OOP stand for?', 'Object-Oriented Programming', 'Object Ordering Process', 'Operating Overloaded Pointers', 'Order of Operations', 'Object-Oriented Programming', 'Easy', 'java'), ('What is a list in Python?', 'A type of loop', 'A built-in function', 'A data structure', 'An object', 'A data structure', 'Easy', 'python'), ('Which data structure uses First-In-First-Out (FIFO) order?', 'Stack', 'Queue', 'Array', 'LinkedList', 'Queue', 'Medium', 'python'), ('What is a constructor?', 'A member of a class', 'A loop in Python', 'A data type', 'A special method', 'A special method', 'Medium', 'java'), ('Which sorting algorithm has the worst-case time complexity of O(n^2)?', 'Merge Sort', 'Quick Sort', 'Insertion Sort', 'Bubble Sort', 'Bubble Sort', 'Hard', 'python'), ('In Java, what is used to create an instance of a class?', 'Class', 'Method', 'Object', 'Constructor', 'Constructor', 'Easy', 'java'), ('Which keyword is used to define a variable that won’t be reassigned?', 'static', 'final', 'constant', 'immutable', 'final', 'Easy', 'java'), ('What is the output of 4 ^ 3 in Python?', '7', '64', '81', '12', '64', 'Easy', 'python'), ('What does the term "polymorphism" refer to in programming?', 'Using multiple inheritance', 'Ability to take multiple forms', 'Manipulating data', 'Using multiple programming languages', 'Ability to take multiple forms', 'Medium', 'java'), ('What is the purpose of the "self" parameter in Python class methods?', 'It refers to the current instance of the class', 'It is used to call parent class methods', 'It is a keyword for loops', 'It is a data type', 'It refers to the current instance of the class', 'Medium', 'python'), ('Which of the following is not a primitive data type in Java?', 'int', 'boolean', 'char', 'string', 'string', 'Medium', 'java'), ('What is the time complexity of a binary search?', 'O(n)', 'O(log n)', 'O(n^2)', 'O(1)', 'O(log n)', 'Medium', 'python'), ('What keyword is used to inherit a class in Python?', 'extends', 'inherits', 'super', 'class', 'class', 'Easy', 'python'), ('Which type of loop is ideal for situations where the number of iterations is known?', 'for loop', 'while loop', 'do-while loop', 'until loop', 'for loop', 'Easy', 'java'), ('What is the purpose of "import" in Python?', 'To export data', 'To create a backup', 'To include external modules', 'To print output', 'To include external modules', 'Easy', 'python'), ('In Java, which access modifier provides the widest visibility?', 'public', 'private', 'protected', 'package-private', 'public', 'Easy', 'java'), ('What is a lambda function in Python?', 'A function that uses the "lambda" keyword', 'A function with multiple return values', 'A function with no parameters', 'An anonymous inline function', 'An anonymous inline function', 'Medium', 'python'), ('What is a linked list?', 'A type of array', 'A linear data structure', 'A collection of objects', 'A group of classes', 'A linear data structure', 'Medium', 'java'), ('Which operator is used to concatenate strings in Python?', '&', '+', '*', '++', '+', 'Easy', 'python'), ('What does JVM stand for?', 'Java Virtual Machine', 'Just Virtual Memory', 'JavaScript Virtual Machine', 'Java Version Manager', 'Java Virtual Machine', 'Easy', 'java'), ('In Python, what is the main difference between a tuple and a list?', 'Tuples are mutable, lists are not', 'Lists are ordered, tuples are not', 'Tuples can store mixed data types, lists cannot', 'Lists have a fixed size, tuples do not', 'Tuples can store mixed data types, lists cannot', 'Medium', 'python'), ('What is the purpose of the "finally" block in a try-catch-finally statement?', 'To handle exceptions', 'To define a fallback value', 'To execute code regardless of exceptions', 'To terminate the program', 'To execute code regardless of exceptions', 'Medium', 'java'), ('What is a dictionary in Python?', 'A sorted collection of elements', 'A data structure used for searching', 'An ordered sequence of elements', 'A key-value store', 'A key-value store', 'Easy', 'python'), ('Which keyword is used to define a subclass in Java?', 'child', 'extends', 'inherits', 'subclass', 'extends', 'Easy', 'java'), ('What is the purpose of the "pass" statement in Python?', 'To stop the execution of a loop', 'To indicate an empty code block', 'To raise an exception', 'To terminate the program', 'To indicate an empty code block', 'Easy', 'python');
Thank you so much bro . If you use this sql codes to create your database keep attention while try to create findByCategory method . Category names are lowercase in this sql code but in the video lecturer have uppercase category name at own db .If you try to search with uppercase postman will give you an empty list . I spent lots of time to realize that . maybe you can save your time .
00:04 We are building a quiz application using Spring Boot. 05:31 Create a REST controller to handle requests for all questions 16:28 Create a model class to represent the table columns 21:37 Create a Question DAO using Spring Data JPA for fetching data from the database 31:34 We can fetch questions by category and retrieve questions based on a specific category. 36:28 Create a method to add a question and return a success message 46:27 Handling exceptions and HTTP response status codes in the question service. 51:23 Handle exceptions and return response entities in controller and service methods. 1:01:17 Create a quiz and send data using a post request 1:06:13 Create a quiz with questions 1:16:03 Successfully created and fetched quiz data 1:21:06 Create a question wrapper class to exclude irrelevant data from the quiz response 1:31:18 Create a method in the controller to submit a quiz and calculate the score. 1:36:33 Created a method in the service for calculating quiz responses
I would like to say thank you to Telusko and your channel. This tutorial about spring has helped and prepared me for a job opportunity for a company that I was aiming for. And now they have sent me an offer that I'm about to sign. Thank you Telusko. More power to you.
I’m attending a bootcamp and currently going through spring boot. This is perfect timing and helps to reinforce the material. Thanks Navin the master Alien❤
@@sauravgheewala8373 did you resolve the issue? this is what I wrote @Query(value = "SELECT * FROM question WHERE question.category =:category ORDER BY random() LIMIT :numQ", nativeQuery = true) List findRandomQuestionsByCategory(String category,int numQ); random questions are not getting generated ); .
@@sauravgheewala8373 @Query(value = "SELECT * FROM question q Where q.category =:category ORDER BY RAND() LIMIT :numQ", nativeQuery = true), getting an error here at LIMIT
Thank you that was great. The only problem is that by this implementation on the quiz submit, the order of responses are important If you change the order of your responses, the index will be different from the questions array, the calculateResult function cannot return the right answer
Excellent beginners project and this will make to develope microservices as well, one thing gap for better understanding is UI, if you upload UI for this project it will very helpful to the students for better understanding
CREATE TABLE "question" ( "id" SERIAL PRIMARY KEY, "category" VARCHAR(25), "difficulty_level" VARCHAR(25), "option1" VARCHAR(255), "option2" VARCHAR(255), "option3" VARCHAR(255), "option4" VARCHAR(255), "question_title" VARCHAR(255), "correct_answer" VARCHAR(255) ); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Geography', 'Easy', 'What is the capital of France?', 'Paris', 'London', 'Rome', 'Berlin', 'Paris'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Literature', 'Medium', 'Who wrote the novel "Moby Dick"?', 'Herman Melville', 'Mark Twain', 'Charles Dickens', 'Leo Tolstoy', 'Herman Melville'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Math', 'Hard', 'What is the square root of 16?', '4', '8', '12', '16', '4'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Science', 'Easy', 'What is the name of the largest planet in the solar system?', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Jupiter'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('History', 'Medium', 'What was the name of the first world war?', 'World War I', 'World War II', 'The Great War', 'The War to End All Wars', 'World War I');
Here is the adjusted query CREATE TABLE "question" ( "id" SERIAL PRIMARY KEY, "category" VARCHAR(25), "difficulty_level" VARCHAR(25), "option1" VARCHAR(255), "option2" VARCHAR(255), "option3" VARCHAR(255), "option4" VARCHAR(255), "question_title" VARCHAR(255), "correct_answer" VARCHAR(255) ); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Geography', 'Easy', 'Paris', 'London', 'Rome', 'Berlin', 'What is the capital of France?', 'Paris'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Literature', 'Medium', 'Herman Melville', 'Mark Twain', 'Charles Dickens', 'Leo Tolstoy', 'Who wrote the novel "Moby Dick"?', 'Herman Melville'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Math', 'Hard', '4', '8', '12', '16', 'What is the square root of 16?', '4'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('Science', 'Easy', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'What is the name of the largest planet in the solar system?', 'Jupiter'); INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer) VALUES ('History', 'Medium', 'World War I', 'World War II', 'The Great War', 'The War to End All Wars', 'What was the name of the first world war?', 'World War I');
CREATE TABLE Question ( id SERIAL PRIMARY KEY, question_title TEXT NOT NULL, option1 TEXT NOT NULL, option2 TEXT NOT NULL, option3 TEXT NOT NULL, option4 TEXT NOT NULL, right_answer TEXT NOT NULL, difficulty_level TEXT NOT NULL, category TEXT NOT NULL ); INSERT INTO Question (question_title, option1, option2, option3, option4, right_answer, difficulty_level, category) VALUES ('What is a class in Java?', 'A function', 'An object', 'A data structure', 'A loop', 'An object', 'Easy', 'java'), ('What does OOP stand for?', 'Object-Oriented Programming', 'Object Ordering Process', 'Operating Overloaded Pointers', 'Order of Operations', 'Object-Oriented Programming', 'Easy', 'java'), ('What is a list in Python?', 'A type of loop', 'A built-in function', 'A data structure', 'An object', 'A data structure', 'Easy', 'python'), ('Which data structure uses First-In-First-Out (FIFO) order?', 'Stack', 'Queue', 'Array', 'LinkedList', 'Queue', 'Medium', 'python'), ('What is a constructor?', 'A member of a class', 'A loop in Python', 'A data type', 'A special method', 'A special method', 'Medium', 'java'), ('Which sorting algorithm has the worst-case time complexity of O(n^2)?', 'Merge Sort', 'Quick Sort', 'Insertion Sort', 'Bubble Sort', 'Bubble Sort', 'Hard', 'python'), ('In Java, what is used to create an instance of a class?', 'Class', 'Method', 'Object', 'Constructor', 'Constructor', 'Easy', 'java'), ('Which keyword is used to define a variable that won’t be reassigned?', 'static', 'final', 'constant', 'immutable', 'final', 'Easy', 'java'), ('What is the output of 4 ^ 3 in Python?', '7', '64', '81', '12', '64', 'Easy', 'python'), ('What does the term "polymorphism" refer to in programming?', 'Using multiple inheritance', 'Ability to take multiple forms', 'Manipulating data', 'Using multiple programming languages', 'Ability to take multiple forms', 'Medium', 'java'), ('What is the purpose of the "self" parameter in Python class methods?', 'It refers to the current instance of the class', 'It is used to call parent class methods', 'It is a keyword for loops', 'It is a data type', 'It refers to the current instance of the class', 'Medium', 'python'), ('Which of the following is not a primitive data type in Java?', 'int', 'boolean', 'char', 'string', 'string', 'Medium', 'java'), ('What is the time complexity of a binary search?', 'O(n)', 'O(log n)', 'O(n^2)', 'O(1)', 'O(log n)', 'Medium', 'python'), ('What keyword is used to inherit a class in Python?', 'extends', 'inherits', 'super', 'class', 'class', 'Easy', 'python'), ('Which type of loop is ideal for situations where the number of iterations is known?', 'for loop', 'while loop', 'do-while loop', 'until loop', 'for loop', 'Easy', 'java'), ('What is the purpose of "import" in Python?', 'To export data', 'To create a backup', 'To include external modules', 'To print output', 'To include external modules', 'Easy', 'python'), ('In Java, which access modifier provides the widest visibility?', 'public', 'private', 'protected', 'package-private', 'public', 'Easy', 'java'), ('What is a lambda function in Python?', 'A function that uses the "lambda" keyword', 'A function with multiple return values', 'A function with no parameters', 'An anonymous inline function', 'An anonymous inline function', 'Medium', 'python'), ('What is a linked list?', 'A type of array', 'A linear data structure', 'A collection of objects', 'A group of classes', 'A linear data structure', 'Medium', 'java'), ('Which operator is used to concatenate strings in Python?', '&', '+', '*', '++', '+', 'Easy', 'python'), ('What does JVM stand for?', 'Java Virtual Machine', 'Just Virtual Memory', 'JavaScript Virtual Machine', 'Java Version Manager', 'Java Virtual Machine', 'Easy', 'java'), ('In Python, what is the main difference between a tuple and a list?', 'Tuples are mutable, lists are not', 'Lists are ordered, tuples are not', 'Tuples can store mixed data types, lists cannot', 'Lists have a fixed size, tuples do not', 'Tuples can store mixed data types, lists cannot', 'Medium', 'python'), ('What is the purpose of the "finally" block in a try-catch-finally statement?', 'To handle exceptions', 'To define a fallback value', 'To execute code regardless of exceptions', 'To terminate the program', 'To execute code regardless of exceptions', 'Medium', 'java'), ('What is a dictionary in Python?', 'A sorted collection of elements', 'A data structure used for searching', 'An ordered sequence of elements', 'A key-value store', 'A key-value store', 'Easy', 'python'), ('Which keyword is used to define a subclass in Java?', 'child', 'extends', 'inherits', 'subclass', 'extends', 'Easy', 'java'), ('What is the purpose of the "pass" statement in Python?', 'To stop the execution of a loop', 'To indicate an empty code block', 'To raise an exception', 'To terminate the program', 'To indicate an empty code block', 'Easy', 'python');
Thanks for this project, really loved it...Need more such videos of Spring Boot projcets which are more advanced and which has spring security, aop and other concepts covered.
Nice video sir. But instead of creating QuestionWrapper class, create a another contructor without having right answer, category,difficulty level in Question class and we can use that ?
I am using MySQL for my database instead of PostgreSQL, and I already have a table with values pre-populated as yours is. However, when I execute my program as you do at 27:38, I get an error saying "Error executing DDL 'create table ...'table 'mytablename' already exists. Please someone help I believe it's trying to create a new table of the same name as my current table in mysql, instead of accessing it to display the values in the browser.
if anyone getting following error its due to wrongly setup database table and primary key not being present in the table- org.hibernate.assertionfailure: null identifier use following query to create question table CREATE TABLE question ( id SERIAL PRIMARY KEY, question_title varchar, option1 varchar, option2 varchar, option3 varchar, option4 varchar, right_answer varchar, difficulty_level varchar, category varchar );
we can use MappingJacksonValue and SimpleBeanPropertyFilter for dynamic filter to Question class for specific api rather than creating new QuizWrapper class
⚠⚠I'm not able to run the nativeQuery for mySql database, while I'm trying to execute the same nativeQuery, is that because the mySql doesn't support parameter binding for LIMIT.. Anyone please help.
When I'm trying to create "QUIZ" using Spring Boot I'm getting this error. "Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Could not determine recommended JdbcType for Java type 'com.project.model.Question' " The SQL query is not executing "SELECT *FROM question q WHERE q.category=:category ORDER BY RANDOM() LIMIT:numQ;" Could anyone please help me sort this?
@@TuanLe-bp9gd I'm using mySQL and while I'm trying to run the nativeQuery I'm getting some error. Any idea why? is it because I'm using mySQL as database which doesn't support parameter binding in LIMIT. please reply
Hey, why the controller not get instantiated when I created in different package but using it in a package which has main class it works fine. Can anybody help on this ?
For post method with category in question controller used pathvariable but in quiz controller used requestparam is there any specific reson behind this?
Do anyone facing this issue? Not able to use setter methods like setTitle , setQuestions while creating a quiz table despite of having lombok dependencies
How do we print any variable or an array to see how the data is or in what format it is. Bcuz here the iteration worked as both response and questions are in same order. But we might have to map the response wih the question... So how do we print some data in springboot? Tried doing in service layer but didnt work!!
when i created the quiz using category, numQ and title. I am getting empty quiz_questions table. I have used MySQL for backend Please suggest me solution.
//This resolved this issue for me - import jakarta.persistence.JoinColumn; @ManyToMany @JoinTable( name = "quiz_questions", // Name of the join table joinColumns = { @JoinColumn(name = "quiz_id") // Array of JoinColumn annotations }, inverseJoinColumns = { @JoinColumn(name = "question_id") // Array of JoinColumn annotations } ) private List questions;
I got the same error here is the solution. I want to contribute in open source. For MYSQL database : create database if not exists questiondb; use questiondb; CREATE TABLE question ( id SERIAL PRIMARY KEY, category VARCHAR(255), difficultylevel VARCHAR(255), option1 VARCHAR(255), option2 VARCHAR(255), option3 VARCHAR(255), option4 VARCHAR(255), question_title VARCHAR(255), right_answer VARCHAR(255) ); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
Failed to create query for method public abstract java.util.List com.Questions.DAO.Question_Dao.findRandomQuestionByCategoryAndnumQ(java.lang.String,int); No property 'andnumQ' found for type 'String'; Traversed path: Questions.category. please explain this
I have an issue on the primary key on the table when i add elements. When i restart the spring boot, the number for the id increments by 50. Are there any solutions for that?
great tutorial..it helped a lot..Thanks🙏🙏 I don't know why, @Data from lombok was not working, when i used it, Empty ArrayList was coming in response...So I made getters and setters and completed the project
1:10:30 - Why are we using @ManyToMany annotation instead of @OneToMany in the Quiz class. It should be @OneToMany right ? coz in one quiz there will be many questions ryt ? but the vice versa is not possible.
hello Reddy Sir. plz describe how you configure postgre into spring project .kindly provide tutorial or describe in short. i have mention this project in resume and i got call for interview . before that i want to finish this project.kindly help me sir
@@abishasherlin5896 I meant we can pass question object and use only the required attributes of question object inside question wrapper. There is no way we are showing answer using question wrapper. That's the whole point of using wrapper r8!😅
I got error when sent post request. { "timestamp": "2023-12-28T19:06:49.031+00:00", "status": 500, "error": "Internal Server Error", "path": "/question/add" } How can I solve ? min: 57.27
For MYSQL database : create database if not exists questiondb; use questiondb; CREATE TABLE question ( id SERIAL PRIMARY KEY, category VARCHAR(255), difficultylevel VARCHAR(255), option1 VARCHAR(255), option2 VARCHAR(255), option3 VARCHAR(255), option4 VARCHAR(255), question_title VARCHAR(255), right_answer VARCHAR(255) ); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "com.sonchayan.Question_demo.model.Response.getResponse()" is null i got this error please help me to solve this
I am facing post method problem --{ "timestamp": "2023-08-21T09:20:10.997+00:00", "status": 415, "error": "Unsupported Media Type", "path": "/question/add" }
when i make function add , it show this org.postgresql.util.PSQLException: ERROR: null value in column "id" of relation "question1" violates not-null constraint.
Thank you so much for this beautiful tutorial. Please, I got this error: java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "com.kay.quizapp.entity.Response.getResponse()" is null. What could I have done wrongly? Regards
sir for delete if we use delete , then we have to provide whole question class, which is lengthy , instead we use deleteById , but for this we need to know id of particular Question how to resolve this issue ?
And whats the problem with that? If you want to delete a question from your database you will need to know the id of it. for ex: @DeleteMapping("/remove/{id}") public ResponseEntity removeQuestion(@PathVariable Integer id) { return questionService.removeQuestion(id); }
when i created the quiz using category, numQ and title. I am getting empty quiz_questions table. I have used MySQL for backend Please suggest me solution.
To beginners means a person without knowledge of the java basics even syntax also can understand this course?? can a person directly understand spring boot without basics of java core or java basic ?? please make a detailed video that a person without the knowledge of java basics can also understand spring boot.
For MYSQL database : create database if not exists questiondb; use questiondb; CREATE TABLE question ( id SERIAL PRIMARY KEY, category VARCHAR(255), difficultylevel VARCHAR(255), option1 VARCHAR(255), option2 VARCHAR(255), option3 VARCHAR(255), option4 VARCHAR(255), question_title VARCHAR(255), right_answer VARCHAR(255) ); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List'); INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
DATABASE for this project
CREATE TABLE Question (
id SERIAL PRIMARY KEY,
question_title TEXT NOT NULL,
option1 TEXT NOT NULL,
option2 TEXT NOT NULL,
option3 TEXT NOT NULL,
option4 TEXT NOT NULL,
right_answer TEXT NOT NULL,
difficulty_level TEXT NOT NULL,
category TEXT NOT NULL
);
INSERT INTO Question (question_title, option1, option2, option3, option4, right_answer, difficulty_level, category)
VALUES
('What is a class in Java?', 'A function', 'An object', 'A data structure', 'A loop', 'An object', 'Easy', 'java'),
('What does OOP stand for?', 'Object-Oriented Programming', 'Object Ordering Process', 'Operating Overloaded Pointers', 'Order of Operations', 'Object-Oriented Programming', 'Easy', 'java'),
('What is a list in Python?', 'A type of loop', 'A built-in function', 'A data structure', 'An object', 'A data structure', 'Easy', 'python'),
('Which data structure uses First-In-First-Out (FIFO) order?', 'Stack', 'Queue', 'Array', 'LinkedList', 'Queue', 'Medium', 'python'),
('What is a constructor?', 'A member of a class', 'A loop in Python', 'A data type', 'A special method', 'A special method', 'Medium', 'java'),
('Which sorting algorithm has the worst-case time complexity of O(n^2)?', 'Merge Sort', 'Quick Sort', 'Insertion Sort', 'Bubble Sort', 'Bubble Sort', 'Hard', 'python'),
('In Java, what is used to create an instance of a class?', 'Class', 'Method', 'Object', 'Constructor', 'Constructor', 'Easy', 'java'),
('Which keyword is used to define a variable that won’t be reassigned?', 'static', 'final', 'constant', 'immutable', 'final', 'Easy', 'java'),
('What is the output of 4 ^ 3 in Python?', '7', '64', '81', '12', '64', 'Easy', 'python'),
('What does the term "polymorphism" refer to in programming?', 'Using multiple inheritance', 'Ability to take multiple forms', 'Manipulating data', 'Using multiple programming languages', 'Ability to take multiple forms', 'Medium', 'java'),
('What is the purpose of the "self" parameter in Python class methods?', 'It refers to the current instance of the class', 'It is used to call parent class methods', 'It is a keyword for loops', 'It is a data type', 'It refers to the current instance of the class', 'Medium', 'python'),
('Which of the following is not a primitive data type in Java?', 'int', 'boolean', 'char', 'string', 'string', 'Medium', 'java'),
('What is the time complexity of a binary search?', 'O(n)', 'O(log n)', 'O(n^2)', 'O(1)', 'O(log n)', 'Medium', 'python'),
('What keyword is used to inherit a class in Python?', 'extends', 'inherits', 'super', 'class', 'class', 'Easy', 'python'),
('Which type of loop is ideal for situations where the number of iterations is known?', 'for loop', 'while loop', 'do-while loop', 'until loop', 'for loop', 'Easy', 'java'),
('What is the purpose of "import" in Python?', 'To export data', 'To create a backup', 'To include external modules', 'To print output', 'To include external modules', 'Easy', 'python'),
('In Java, which access modifier provides the widest visibility?', 'public', 'private', 'protected', 'package-private', 'public', 'Easy', 'java'),
('What is a lambda function in Python?', 'A function that uses the "lambda" keyword', 'A function with multiple return values', 'A function with no parameters', 'An anonymous inline function', 'An anonymous inline function', 'Medium', 'python'),
('What is a linked list?', 'A type of array', 'A linear data structure', 'A collection of objects', 'A group of classes', 'A linear data structure', 'Medium', 'java'),
('Which operator is used to concatenate strings in Python?', '&', '+', '*', '++', '+', 'Easy', 'python'),
('What does JVM stand for?', 'Java Virtual Machine', 'Just Virtual Memory', 'JavaScript Virtual Machine', 'Java Version Manager', 'Java Virtual Machine', 'Easy', 'java'),
('In Python, what is the main difference between a tuple and a list?', 'Tuples are mutable, lists are not', 'Lists are ordered, tuples are not', 'Tuples can store mixed data types, lists cannot', 'Lists have a fixed size, tuples do not', 'Tuples can store mixed data types, lists cannot', 'Medium', 'python'),
('What is the purpose of the "finally" block in a try-catch-finally statement?', 'To handle exceptions', 'To define a fallback value', 'To execute code regardless of exceptions', 'To terminate the program', 'To execute code regardless of exceptions', 'Medium', 'java'),
('What is a dictionary in Python?', 'A sorted collection of elements', 'A data structure used for searching', 'An ordered sequence of elements', 'A key-value store', 'A key-value store', 'Easy', 'python'),
('Which keyword is used to define a subclass in Java?', 'child', 'extends', 'inherits', 'subclass', 'extends', 'Easy', 'java'),
('What is the purpose of the "pass" statement in Python?', 'To stop the execution of a loop', 'To indicate an empty code block', 'To raise an exception', 'To terminate the program', 'To indicate an empty code block', 'Easy', 'python');
select * from "Question"
Thanks Man ✌✌
Thanks a lot
Thankz
Thank you so much bro . If you use this sql codes to create your database keep attention while try to create findByCategory method . Category names are lowercase in this sql code but in the video lecturer have uppercase category name at own db .If you try to search with uppercase postman will give you an empty list . I spent lots of time to realize that . maybe you can save your time .
Thank Man
00:04 We are building a quiz application using Spring Boot.
05:31 Create a REST controller to handle requests for all questions
16:28 Create a model class to represent the table columns
21:37 Create a Question DAO using Spring Data JPA for fetching data from the database
31:34 We can fetch questions by category and retrieve questions based on a specific category.
36:28 Create a method to add a question and return a success message
46:27 Handling exceptions and HTTP response status codes in the question service.
51:23 Handle exceptions and return response entities in controller and service methods.
1:01:17 Create a quiz and send data using a post request
1:06:13 Create a quiz with questions
1:16:03 Successfully created and fetched quiz data
1:21:06 Create a question wrapper class to exclude irrelevant data from the quiz response
1:31:18 Create a method in the controller to submit a quiz and calculate the score.
1:36:33 Created a method in the service for calculating quiz responses
I would like to say thank you to Telusko and your channel. This tutorial about spring has helped and prepared me for a job opportunity for a company that I was aiming for. And now they have sent me an offer that I'm about to sign.
Thank you Telusko. More power to you.
Bro can u guide me
I’m attending a bootcamp and currently going through spring boot. This is perfect timing and helps to reinforce the material.
Thanks Navin the master Alien❤
which boot camp are you joining , can u please share ?
Is it Vlad Mishustin's bootcamp? :))
@@kafychannel where can i get the links for it
1:14:54 Hear Write Rand() insted of Random() Cause Random() is not working properly... Thank You Navin Sir You Inspire me a lot......
still not working
@@harshitgupta1034 what query you wrote ?
@@sauravgheewala8373 did you resolve the issue?
this is what I wrote
@Query(value = "SELECT * FROM question WHERE question.category =:category ORDER BY random() LIMIT :numQ", nativeQuery = true)
List findRandomQuestionsByCategory(String category,int numQ);
random questions
are not getting generated ); .
@@sauravgheewala8373 @Query(value = "SELECT * FROM question q Where q.category =:category ORDER BY RAND() LIMIT :numQ", nativeQuery = true), getting an error here at LIMIT
Damn I was breaking my head since last 2 days for this..after using Rand() the code is working fine now.
Thank you that was great.
The only problem is that by this implementation on the quiz submit, the order of responses are important
If you change the order of your responses, the index will be different from the questions array, the calculateResult function cannot return the right answer
yeah , i got the same issue , why its happening
Excellent beginners project and this will make to develope microservices as well, one thing gap for better understanding is UI, if you upload UI for this project it will very helpful to the students for better understanding
Just for Tip : sql user set id = 0 as default value it will not give u error
Wow! Very well explained and covered all the topics with clarity!
CREATE TABLE "question" (
"id" SERIAL PRIMARY KEY,
"category" VARCHAR(25),
"difficulty_level" VARCHAR(25),
"option1" VARCHAR(255),
"option2" VARCHAR(255),
"option3" VARCHAR(255),
"option4" VARCHAR(255),
"question_title" VARCHAR(255),
"correct_answer" VARCHAR(255)
);
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Geography', 'Easy', 'What is the capital of France?', 'Paris', 'London', 'Rome', 'Berlin', 'Paris');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Literature', 'Medium', 'Who wrote the novel "Moby Dick"?', 'Herman Melville', 'Mark Twain', 'Charles Dickens', 'Leo Tolstoy', 'Herman Melville');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Math', 'Hard', 'What is the square root of 16?', '4', '8', '12', '16', '4');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Science', 'Easy', 'What is the name of the largest planet in the solar system?', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'Jupiter');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('History', 'Medium', 'What was the name of the first world war?', 'World War I', 'World War II', 'The Great War', 'The War to End All Wars', 'World War I');
Thanks 🙏🏿
thanksssss
Thank You So Much
Here is the adjusted query
CREATE TABLE "question" (
"id" SERIAL PRIMARY KEY,
"category" VARCHAR(25),
"difficulty_level" VARCHAR(25),
"option1" VARCHAR(255),
"option2" VARCHAR(255),
"option3" VARCHAR(255),
"option4" VARCHAR(255),
"question_title" VARCHAR(255),
"correct_answer" VARCHAR(255)
);
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Geography', 'Easy', 'Paris', 'London', 'Rome', 'Berlin', 'What is the capital of France?', 'Paris');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Literature', 'Medium', 'Herman Melville', 'Mark Twain', 'Charles Dickens', 'Leo Tolstoy', 'Who wrote the novel "Moby Dick"?', 'Herman Melville');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Math', 'Hard', '4', '8', '12', '16', 'What is the square root of 16?', '4');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('Science', 'Easy', 'Jupiter', 'Saturn', 'Uranus', 'Neptune', 'What is the name of the largest planet in the solar system?', 'Jupiter');
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('History', 'Medium', 'World War I', 'World War II', 'The Great War', 'The War to End All Wars', 'What was the name of the first world war?', 'World War I');
@@aman_ Thanks for the help 😘😘🥰
Very nice and deep explanation i learnt a lot from this video thank you so much sir 🙏🏼🙏🏼🙏🏼
CREATE TABLE Question (
id SERIAL PRIMARY KEY,
question_title TEXT NOT NULL,
option1 TEXT NOT NULL,
option2 TEXT NOT NULL,
option3 TEXT NOT NULL,
option4 TEXT NOT NULL,
right_answer TEXT NOT NULL,
difficulty_level TEXT NOT NULL,
category TEXT NOT NULL
);
INSERT INTO Question (question_title, option1, option2, option3, option4, right_answer, difficulty_level, category)
VALUES
('What is a class in Java?', 'A function', 'An object', 'A data structure', 'A loop', 'An object', 'Easy', 'java'),
('What does OOP stand for?', 'Object-Oriented Programming', 'Object Ordering Process', 'Operating Overloaded Pointers', 'Order of Operations', 'Object-Oriented Programming', 'Easy', 'java'),
('What is a list in Python?', 'A type of loop', 'A built-in function', 'A data structure', 'An object', 'A data structure', 'Easy', 'python'),
('Which data structure uses First-In-First-Out (FIFO) order?', 'Stack', 'Queue', 'Array', 'LinkedList', 'Queue', 'Medium', 'python'),
('What is a constructor?', 'A member of a class', 'A loop in Python', 'A data type', 'A special method', 'A special method', 'Medium', 'java'),
('Which sorting algorithm has the worst-case time complexity of O(n^2)?', 'Merge Sort', 'Quick Sort', 'Insertion Sort', 'Bubble Sort', 'Bubble Sort', 'Hard', 'python'),
('In Java, what is used to create an instance of a class?', 'Class', 'Method', 'Object', 'Constructor', 'Constructor', 'Easy', 'java'),
('Which keyword is used to define a variable that won’t be reassigned?', 'static', 'final', 'constant', 'immutable', 'final', 'Easy', 'java'),
('What is the output of 4 ^ 3 in Python?', '7', '64', '81', '12', '64', 'Easy', 'python'),
('What does the term "polymorphism" refer to in programming?', 'Using multiple inheritance', 'Ability to take multiple forms', 'Manipulating data', 'Using multiple programming languages', 'Ability to take multiple forms', 'Medium', 'java'),
('What is the purpose of the "self" parameter in Python class methods?', 'It refers to the current instance of the class', 'It is used to call parent class methods', 'It is a keyword for loops', 'It is a data type', 'It refers to the current instance of the class', 'Medium', 'python'),
('Which of the following is not a primitive data type in Java?', 'int', 'boolean', 'char', 'string', 'string', 'Medium', 'java'),
('What is the time complexity of a binary search?', 'O(n)', 'O(log n)', 'O(n^2)', 'O(1)', 'O(log n)', 'Medium', 'python'),
('What keyword is used to inherit a class in Python?', 'extends', 'inherits', 'super', 'class', 'class', 'Easy', 'python'),
('Which type of loop is ideal for situations where the number of iterations is known?', 'for loop', 'while loop', 'do-while loop', 'until loop', 'for loop', 'Easy', 'java'),
('What is the purpose of "import" in Python?', 'To export data', 'To create a backup', 'To include external modules', 'To print output', 'To include external modules', 'Easy', 'python'),
('In Java, which access modifier provides the widest visibility?', 'public', 'private', 'protected', 'package-private', 'public', 'Easy', 'java'),
('What is a lambda function in Python?', 'A function that uses the "lambda" keyword', 'A function with multiple return values', 'A function with no parameters', 'An anonymous inline function', 'An anonymous inline function', 'Medium', 'python'),
('What is a linked list?', 'A type of array', 'A linear data structure', 'A collection of objects', 'A group of classes', 'A linear data structure', 'Medium', 'java'),
('Which operator is used to concatenate strings in Python?', '&', '+', '*', '++', '+', 'Easy', 'python'),
('What does JVM stand for?', 'Java Virtual Machine', 'Just Virtual Memory', 'JavaScript Virtual Machine', 'Java Version Manager', 'Java Virtual Machine', 'Easy', 'java'),
('In Python, what is the main difference between a tuple and a list?', 'Tuples are mutable, lists are not', 'Lists are ordered, tuples are not', 'Tuples can store mixed data types, lists cannot', 'Lists have a fixed size, tuples do not', 'Tuples can store mixed data types, lists cannot', 'Medium', 'python'),
('What is the purpose of the "finally" block in a try-catch-finally statement?', 'To handle exceptions', 'To define a fallback value', 'To execute code regardless of exceptions', 'To terminate the program', 'To execute code regardless of exceptions', 'Medium', 'java'),
('What is a dictionary in Python?', 'A sorted collection of elements', 'A data structure used for searching', 'An ordered sequence of elements', 'A key-value store', 'A key-value store', 'Easy', 'python'),
('Which keyword is used to define a subclass in Java?', 'child', 'extends', 'inherits', 'subclass', 'extends', 'Easy', 'java'),
('What is the purpose of the "pass" statement in Python?', 'To stop the execution of a loop', 'To indicate an empty code block', 'To raise an exception', 'To terminate the program', 'To indicate an empty code block', 'Easy', 'python');
select * from "Question"
Thanks alot.
Amazing video. Thank you so much! This video really made me confident in the beginning of learning back end dev with Java.
Super. Covered all the theories in one go.
Thanks a lot sir😊
which IDE is used here? Intellij?
Thanks for this project, really loved it...Need more such videos of Spring Boot projcets which are more advanced and which has spring security, aop and other concepts covered.
Nice video sir. But instead of creating QuestionWrapper class, create a another contructor without having right answer, category,difficulty level in Question class and we can use that ?
from where to copy your sql code? please provide somewhere so that we could save some of the time
You are master of your art
respect ++
I am using MySQL for my database instead of PostgreSQL, and I already have a table with values pre-populated as yours is. However, when I execute my program as you do at 27:38, I get an error saying "Error executing DDL 'create table ...'table 'mytablename' already exists. Please someone help I believe it's trying to create a new table of the same name as my current table in mysql, instead of accessing it to display the values in the browser.
check ur application properties once and name of the column in db
In my case it was the same , it has created a new table ,later i have changed the table and also the question entity ,it resolved the error
if anyone getting following error its due to wrongly setup database table and primary key not being present in the table-
org.hibernate.assertionfailure: null identifier
use following query to create question table
CREATE TABLE question (
id SERIAL PRIMARY KEY,
question_title varchar,
option1 varchar,
option2 varchar,
option3 varchar,
option4 varchar,
right_answer varchar,
difficulty_level varchar,
category varchar
);
we can use MappingJacksonValue and SimpleBeanPropertyFilter for dynamic filter to Question class for specific api rather than creating new QuizWrapper class
I want that sql table.. can you upload that also in git, Naveen?
Sir from where we will get the database . Please provide any link to access the database of the quiz app
⚠⚠I'm not able to run the nativeQuery for mySql database, while I'm trying to execute the same nativeQuery, is that because the mySql doesn't support parameter binding for LIMIT..
Anyone please help.
Easy to understand, you are awesome sir
Amazing explanation 😉.Thanks for giving such type of video
My questions are not appearing it's giving me a null list. What should I do.
Same HERE 1:18:08 did fix it ma'am
When I'm trying to create "QUIZ" using Spring Boot I'm getting this error.
"Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Could not determine recommended JdbcType for Java type 'com.project.model.Question' "
The SQL query is not executing
"SELECT *FROM question q WHERE q.category=:category ORDER BY RANDOM() LIMIT:numQ;"
Could anyone please help me sort this?
Which database do you use?
@@TuanLe-bp9gd I'm using mySQL and while I'm trying to run the nativeQuery I'm getting some error. Any idea why? is it because I'm using mySQL as database which doesn't support parameter binding in LIMIT.
please reply
Hey, why the controller not get instantiated when I created in different package but using it in a package which has main class it works fine. Can anybody help on this ?
Same issue I am also getting. I remember fixing this long back but now I forgot again :D
For post method with category in question controller used pathvariable but in quiz controller used requestparam is there any specific reson behind this?
at 1:11:50 why are we using ' Quiz quiz = new Quiz(); ' ie.e manually creating quiz object; can't we autowire the quiz object.?
Can anyone share the csv file(Questions & QUIZ) don't see that in Description
Do anyone facing this issue? Not able to use setter methods like setTitle , setQuestions while creating a quiz table despite of having lombok dependencies
Use @Data in model class
same here. How did you manage to solve it?
help me with this error
Great job , please add a api which has hashmap return type
Here is the SQL query for a postgresql db for this project with example data(all hail the ai overlords :) ):
DROP TABLE IF EXISTS "question";
CREATE TABLE "question" (
"id" SERIAL PRIMARY KEY,
"category" VARCHAR(25) DEFAULT NULL,
"difficulty_level" VARCHAR(25) DEFAULT NULL,
"option1" VARCHAR(2550) DEFAULT NULL,
"option2" VARCHAR(2550) DEFAULT NULL,
"option3" VARCHAR(2550) DEFAULT NULL,
"option4" VARCHAR(2550) DEFAULT NULL,
"question_title" VARCHAR(2550) DEFAULT NULL,
"correct_answer" VARCHAR(1) DEFAULT NULL
);
-- Question 1
INSERT INTO "question" (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'EASY', 'A. A constant value', 'B. A reserved keyword', 'C. A container for storing data', 'D. A loop control structure', 'What is a variable in Java?', 'C');
-- Question 2
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'EASY', 'A. True', 'B. False', 'C. None', 'D. Both A and B', 'Is Python a dynamically typed language?', 'A');
-- Question 3
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'MEDIUM', 'A. 8', 'B. 16', 'C. 32', 'D. 64', 'How many bits are in a Java long data type?', 'D');
-- Question 4
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'MEDIUM', 'A. Function', 'B. Class', 'C. Method', 'D. Variable', 'What is a group of related statements that perform a specific task in Python?', 'A');
-- Question 5
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'HARD', 'A. Encapsulation', 'B. Polymorphism', 'C. Inheritance', 'D. Abstraction', 'Which OOP concept allows restricting access to certain members of a class?', 'A');
-- Question 6
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'EASY', 'A. List', 'B. Set', 'C. Tuple', 'D. Dictionary', 'Which data type in Python is ordered and mutable?', 'A');
-- Question 7
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'MEDIUM', 'A. ArrayList', 'B. LinkedList', 'C. HashSet', 'D. TreeMap', 'Which Java collection stores elements in a sorted order?', 'D');
-- Question 8
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'HARD', 'A. Recursion', 'B. Iteration', 'C. Abstraction', 'D. Encapsulation', 'What is the process in which a function calls itself directly or indirectly?', 'A');
-- Question 9
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'EASY', 'A. JVM', 'B. JRE', 'C. JDK', 'D. JAR', 'Which component is responsible for executing Java programs?', 'A');
-- Question 10
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'MEDIUM', 'A. Pass by Value', 'B. Pass by Reference', 'C. Pass by Object', 'D. Pass by Assignment', 'How are arguments passed to functions in Python?', 'C');
-- Question 11
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'HARD', 'A. Checked Exception', 'B. Unchecked Exception', 'C. Runtime Exception', 'D. Compile-time Exception', 'Which type of exception is not required to be caught or declared?', 'B');
-- Question 12
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'EASY', 'A. Class', 'B. Object', 'C. Module', 'D. Package', 'In Python, what is an instance of a class called?', 'B');
-- Question 13
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'MEDIUM', 'A. 127', 'B. 255', 'C. 32767', 'D. 2147483647', 'What is the maximum value that can be stored in a Java byte data type?', 'A');
-- Question 14
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'HARD', 'A. Class', 'B. Function', 'C. Module', 'D. Package', 'In Python, which one is a reusable piece of code that encapsulates attributes and behaviors?', 'A');
-- Question 15
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('JAVA', 'EASY', 'A. String', 'B. StringBuilder', 'C. StringBuffer', 'D. Character', 'Which Java class is used for mutable string manipulation?', 'B');
-- Question 16
INSERT INTO question (category, difficulty_level, option1, option2, option3, option4, question_title, correct_answer)
VALUES ('PYTHON', 'MEDIUM', 'A. for loop', 'B. while loop', 'C. do-while loop', 'D. foreach loop', 'In Python, which loop is used for iterating over a sequence?', 'B');
How do we print any variable or an array to see how the data is or in what format it is. Bcuz here the iteration worked as both response and questions are in same order. But we might have to map the response wih the question... So how do we print some data in springboot?
Tried doing in service layer but didnt work!!
when i created the quiz using category, numQ and title. I am getting empty quiz_questions table.
I have used MySQL for backend Please suggest me solution.
//This resolved this issue for me -
import jakarta.persistence.JoinColumn;
@ManyToMany
@JoinTable(
name = "quiz_questions", // Name of the join table
joinColumns = {
@JoinColumn(name = "quiz_id") // Array of JoinColumn annotations
},
inverseJoinColumns = {
@JoinColumn(name = "question_id") // Array of JoinColumn annotations
}
)
private List questions;
I got the same error here is the solution. I want to contribute in open source.
For MYSQL database :
create database if not exists questiondb;
use questiondb;
CREATE TABLE question (
id SERIAL PRIMARY KEY,
category VARCHAR(255),
difficultylevel VARCHAR(255),
option1 VARCHAR(255),
option2 VARCHAR(255),
option3 VARCHAR(255),
option4 VARCHAR(255),
question_title VARCHAR(255),
right_answer VARCHAR(255)
);
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
Hi any help would be appreciated !! GOT STUCK , I am not getting questions in quiz_questions table? Used the same query not able to fetch questions?
facing same issue, any solution?
Any solution ?
same issue im getting only {} as response. data is not getting fetched. but not getting any errors also.
Create a controller to group the employees by contract type and get the number of employees in each group,👈can u please explain this
Failed to create query for method public abstract java.util.List com.Questions.DAO.Question_Dao.findRandomQuestionByCategoryAndnumQ(java.lang.String,int); No property 'andnumQ' found for type 'String'; Traversed path: Questions.category. please explain this
How to learn Frontend Part for this and to make it ?
I have an issue on the primary key on the table when i add elements. When i restart the spring boot, the number for the id increments by 50. Are there any solutions for that?
Good video for beginners showing how you set up a basic Spring Boot project.
I really enjoyed project 👍
hello sagar how u made postgre connection with project . have u done with that ?
Awesome, thank you ❤
Just UI maybe with Angular or React, and beginners like me will enjoy. Thank you again
Hi , GOT STUCK , I am not getting questions in quiz_questions table? Used the same query not able to fetch questions?
I am having the same issue.
I am also having the same issue.
@@jayasrikirubanandam8693 change case of category string in postman from "Java" to "java": .../quiz/create?category=java&numQ=5&title=JQuiz
great tutorial..it helped a lot..Thanks🙏🙏
I don't know why, @Data from lombok was not working, when i used it, Empty ArrayList was coming in response...So I made getters and setters and completed the project
Thanks a lot, same issue i faced it and got a result as you suggested
If you are using STS, you have to first download lombak jar file in maven repository in your local system then you can use it
@jayasrikirubanandam8693 change case of category string in postman from "Java" to "java": .../quiz/create?category=java&numQ=5&title=JQuiz
If I use @Controller instead of RestController to make a Web page. So how can I send data from the Controller to display in jsp?
More Spring Boot projects please!
Lombok @Data doesn't work on my machine, becouse you need install it and do project maven update.
Same, I manually generated getters and setters since using @Data from lombok just ouputted an empty list.
Why I have to make getter and setter when setTitle is used as use lambok ??
so beautiful so elegent just looking like a Jhonny Sins
SIR CAN U PLEASE WORK ON PLAYLISTS SO THAT IN PLAYLIST SECTION WE CAN FIND ALL VIDEOS IN ONCE PLACE
Can anybody help me pls, I'm not able to open the zip file in Intellij Idea 🥺🥺
How to create DeleteMapping, i am getting exception "foreign key constraint"
1:10:30 - Why are we using @ManyToMany annotation instead of @OneToMany in the Quiz class. It should be @OneToMany right ? coz in one quiz there will be many questions ryt ? but the vice versa is not possible.
encountering 405 method not allowed while sending the request for the quiz controller to create a quiz....please help Telusko
Maybe you send the request as GET when you should do it as POST method
Hm, would you say the entire "Restful web services in Java" playlist is still relevant even though it is 6 years old?
can anyone tell how to create quizdb??please help me
helped in many ways thank you so much ,remembered forever
How to work with the same example by using hibernate instead of jpa
Thank you so much!! Learnt a lot.❤
hello Reddy Sir. plz describe how you configure postgre into spring project .kindly provide tutorial or describe in short. i have mention this project in resume and i got call for interview . before that i want to finish this project.kindly help me sir
Did you cleared your interview?
how to add the path in requestmapping? like @Requestmapping(path)
I am completely new to spring boot.
From where we can access the database that you are using . Can anybody help me with that
how to create quizdb?pleasse any one help me
How easy to convert spring to spring boot? Is it possible to call spring functions from spring boot REST API?
I believe we can directly pass Question object into QuestionWrapper constructor instead of sending multiple parameters.
I think we can't, bcz we don't need all variables from Question class..the reason is user should get the question without right ans, diff level..
@@abishasherlin5896 I meant we can pass question object and use only the required attributes of question object inside question wrapper. There is no way we are showing answer using question wrapper. That's the whole point of using wrapper r8!😅
Hi , i need some help code base , how to communicate with you
Quiz_questions table is empty. How do we solve this problem?
same issue
Any solution ?
I got error when sent post request. {
"timestamp": "2023-12-28T19:06:49.031+00:00",
"status": 500,
"error": "Internal Server Error",
"path": "/question/add"
}
How can I solve ?
min: 57.27
check the table attributes in the DB
column name should match the variable name in the entity class for the respective table
great tutorial as usual thank you so much
simply awesome 🥰 thank you
Hi , does any one know how to translate the values in jira payload from user's locale to english ?( Not in the UI)
can you provide the data you are using so that we can use the same data?
For MYSQL database :
create database if not exists questiondb;
use questiondb;
CREATE TABLE question (
id SERIAL PRIMARY KEY,
category VARCHAR(255),
difficultylevel VARCHAR(255),
option1 VARCHAR(255),
option2 VARCHAR(255),
option3 VARCHAR(255),
option4 VARCHAR(255),
question_title VARCHAR(255),
right_answer VARCHAR(255)
);
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
Can anyone pls tell the payload which is passed for create quiz api?
How spring boot to call multiple data tables from DB?
please make video on spring oauth and form login and log out
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "com.sonchayan.Question_demo.model.Response.getResponse()" is null
i got this error please help me to solve this
Sir I have one doubt in java collections api why we use Wrapper classes in key instead of primitive data types in hashmap? can you explain me
because collection api doesn't support primitive types , that's where wrapper class comes into picture
I am facing post method problem --{
"timestamp": "2023-08-21T09:20:10.997+00:00",
"status": 415,
"error": "Unsupported Media Type",
"path": "/question/add"
}
Are you sending the data in json format from postman?
@@alokbhushan9026
yes
please let me know from you set up the database
when i make function add , it show this
org.postgresql.util.PSQLException: ERROR: null value in column "id" of relation "question1" violates not-null constraint.
Does the Quiz table automatically get created?
Thank you so much for this beautiful tutorial. Please, I got this error: java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "com.kay.quizapp.entity.Response.getResponse()" is null. What could I have done wrongly? Regards
I have fixed it. I was sending "reponse" in PostMan instead of " response'. Thanks a lot for your guides. Have a great week.
Whats the difference between @RestController vs @Controller
CREATE TABLE IF NOT EXISTS question (
id SERIAL PRIMARY KEY,
category VARCHAR(25),
difficulty_level VARCHAR(25),
option1 VARCHAR(255),
option2 VARCHAR(255),
option3 VARCHAR(255),
option4 VARCHAR(255),
question_title VARCHAR(255),
correct_answer VARCHAR(255)
);
how to create the table in postgre provide something
Anybody knows IntellijIdea plugin to format the SQL query
❤❤❤osm explanations
sir for delete if we use delete , then we have to provide whole question class, which is lengthy , instead we use deleteById , but for this we need to know id of particular Question
how to resolve this issue ?
And whats the problem with that? If you want to delete a question from your database you will need to know the id of it.
for ex:
@DeleteMapping("/remove/{id}")
public ResponseEntity removeQuestion(@PathVariable Integer id) {
return questionService.removeQuestion(id);
}
@@SpriTeGaimngHD thanks bro. But i have tried it without writing ResponseEntity instead just simple String and it worked fine
when i created the quiz using category, numQ and title. I am getting empty quiz_questions table.
I have used MySQL for backend Please suggest me solution.
same issue
have you solved that ?
change case of category string in postman from "Java" to "java": .../quiz/create?category=java&numQ=5&title=JQuiz
Hlo I am not Getting the data in 28 th minute,can u please explain?
I am also not getting the data
I got the solution - It may be because of lombok, so create getter and setter, constructor using flelds , constructor from superclass and toString
Thanks!!! worked@@honeysungra2749
It's not for Beginners -
First Learn PostgreSQL
Second Learn Spring Boot
Then you can follow up with this project
This is so fun ! thanks bro
How those two table are generated ,is it done already manually aur created automatically ?
It will be automatically created because we are using Mapping right ManyTOMany
Hey where can i get db dump?
To beginners means a person without knowledge of the java basics even syntax also can understand this course?? can a person directly understand spring boot without basics of java core or java basic ?? please make a detailed video that a person without the knowledge of java basics can also understand spring boot.
🤡that's like learning to make Biryani without knowing how to make Maggi
Really very nice and helpful sir
where can i get the database
For MYSQL database :
create database if not exists questiondb;
use questiondb;
CREATE TABLE question (
id SERIAL PRIMARY KEY,
category VARCHAR(255),
difficultylevel VARCHAR(255),
option1 VARCHAR(255),
option2 VARCHAR(255),
option3 VARCHAR(255),
option4 VARCHAR(255),
question_title VARCHAR(255),
right_answer VARCHAR(255)
);
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('1', 'JAVA', 'Easy', 'class', 'interface', 'extends', 'implements', 'Which Java keyword is used to create a subclass?', 'extends');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('2', 'Java', 'Easy', '4', '5', '6', 'Compile error', 'What is the output of the following Java code snippet?', '5');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('3', 'Java', 'Easy', 'TRUE', 'TRUE', '0', 'null', 'In Java, what is the default value of an uninitialized boolean variable?', 'FALSE');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('4', 'Java', 'Easy', 'throw', 'try', 'catch', 'finally', 'Which Java keyword is used to explicitly throw an exception?', 'throw');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('5', 'Java', 'Easy', 'It indicates that a variable is constant.', 'It indicates that a variable is constant.', 'It indicates that a class cannot be extended.', 'It indicates that a variable is of primitive type.', 'What does the static keyword mean in Java?', 'It indicates that a method can be accessed without creating an instance of');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('6', 'Java', 'Easy', 'constant int x = 5;', 'final int x = 5;', 'static int x = 5;', 'readonly int x = 5.', 'What is the correct way to declare a constant variable in Java?', 'final int x = 5;');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('7', 'Java', 'Easy', 'for loop', 'while loop', 'do-while loop', 'switch loop', 'Which loop in Java allows the code to be executed at least once?', 'do-while loop');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('8', 'Java', 'Easy', 'To terminate a loop or switch statement and transfer control to the next stateme....', 'To skip the rest of the code in a loop and move to the next iteration.', 'To define a label for a loop or switch statement', 'To check a condition and execute a block of code repeated', 'What is the purpose of the \'break\' statement in Java?', 'To terminate a loop or switch statement and transfer control to the next statement');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('9', 'Java', 'Easy', '+', '-', '*', '/', 'Which Java operator is used to concatenate two strings?', '*');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('10', 'Java', 'Easy', 'HashMap', 'ArrayList', 'LinkedList', 'HashSet', 'In Java, which collection class provides an implementation of a dynamic array?', 'ArrayList');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('11', 'Python', 'Easy', 'count()', 'size()', 'length()', 'len()', 'Which Python function is used to calculate the length of a list?', 'Len ()');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('12', 'Python', 'Easy', '[1,2,3]', '[1,2,3,4]', '[4,3,2,11]', 'Error', 'What is the output of the following Python code snippet?', '[1,2,3,4]');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('13', 'Python', 'Easy', 'break', 'continue', 'pass', 'return', 'Which Python statement is used to exit from a loop prematurely?', 'break');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('14', 'Python', 'Easy', 'To generate a random number within a given range.', 'To iterate over a sequence of numbers.', 'To sort a list in ascending order.', 'To calculate the length of a string', 'What is the purpose of the range () function in Python?', 'To iterate over a sequence of numbers.');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('15', 'Python', 'Python', 'int', 'float', '|str', 'List', 'In Python, which data type is mutable?', 'List');
INSERT INTO `questiondb`.`question` (`id`, `category`, `difficultylevel`, `option1`, `option2`, `option3`, `option4`, `question_title`, `right_answer`) VALUES ('16', 'Python', 'Python', 'datetime', 'math', 'os', 'sys', 'Which Python module is used for working with dates and times?', 'datetime');
Can someone share the database file for this project for MYSQL