Danix
Danix
JCHJava Community | Help. Code. Learn.
Created by Danix on 10/29/2024 in #java-help
Error: Could not find or load main class
@dan1st can u help ?
9 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
@GAS not liquid
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
@Override
public Optional<StudentDetails> getStudentDetailsByIdForDeleting(Long roll_no) {
Optional<StudentDetails> studentDetails = detailsRepository.findById(roll_no);
if (studentDetails.isPresent()) {
StudentDetails studentDetailsOptional = studentDetails.get();
return Optional.of(studentDetailsOptional);
}
return Optional.empty();
}
@Override
public Optional<StudentDetails> getStudentDetailsByIdForDeleting(Long roll_no) {
Optional<StudentDetails> studentDetails = detailsRepository.findById(roll_no);
if (studentDetails.isPresent()) {
StudentDetails studentDetailsOptional = studentDetails.get();
return Optional.of(studentDetailsOptional);
}
return Optional.empty();
}
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
Can anyone help
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
I dont know why this error
llers.AdminController#studentAllBooks(Long, Model)
2024-09-28T20:27:57.996+05:30 DEBUG 6724 --- [nio-8080-exec-1] org.hibernate.SQL : select sd1_0.roll_no,sd1_0.email,sd1_0.name,sd1_0.phone_number from student_details sd1_0 where sd1_0.roll_no=?
Hibernate: select sd1_0.roll_no,sd1_0.email,sd1_0.name,sd1_0.phone_number from student_details sd1_0 where sd1_0.roll_no=?
2024-09-28T20:27:58.002+05:30 DEBUG 6724 --- [nio-8080-exec-1] org.hibernate.SQL : select bd1_0.user_roll_no,bd1_0.book_id,bd1_0.authors,bd1_0.book_name,bd1_0.book_pdf,bd1_0.currency_code,bd1_0.description,bd1_0.image,bd1_0.issue_date,bd1_0.price,bd1_0.publish_date,bd1_0.return_date,bd1_0.subtitle,bd1_0.synposis from book_details bd1_0 where bd1_0.user_roll_no=?
Hibernate: select bd1_0.user_roll_no,bd1_0.book_id,bd1_0.authors,bd1_0.book_name,bd1_0.book_pdf,bd1_0.currency_code,bd1_0.description,bd1_0.image,bd1_0.issue_date,bd1_0.price,bd1_0.publish_date,bd1_0.return_date,bd1_0.subtitle,bd1_0.synposis from book_details bd1_0 where bd1_0.user_roll_no=?
2024-09-28T20:27:58.005+05:30 DEBUG 6724 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7]
2024-09-28T20:27:58.009+05:30 DEBUG 6724 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed 200 OK
llers.AdminController#studentAllBooks(Long, Model)
2024-09-28T20:27:57.996+05:30 DEBUG 6724 --- [nio-8080-exec-1] org.hibernate.SQL : select sd1_0.roll_no,sd1_0.email,sd1_0.name,sd1_0.phone_number from student_details sd1_0 where sd1_0.roll_no=?
Hibernate: select sd1_0.roll_no,sd1_0.email,sd1_0.name,sd1_0.phone_number from student_details sd1_0 where sd1_0.roll_no=?
2024-09-28T20:27:58.002+05:30 DEBUG 6724 --- [nio-8080-exec-1] org.hibernate.SQL : select bd1_0.user_roll_no,bd1_0.book_id,bd1_0.authors,bd1_0.book_name,bd1_0.book_pdf,bd1_0.currency_code,bd1_0.description,bd1_0.image,bd1_0.issue_date,bd1_0.price,bd1_0.publish_date,bd1_0.return_date,bd1_0.subtitle,bd1_0.synposis from book_details bd1_0 where bd1_0.user_roll_no=?
Hibernate: select bd1_0.user_roll_no,bd1_0.book_id,bd1_0.authors,bd1_0.book_name,bd1_0.book_pdf,bd1_0.currency_code,bd1_0.description,bd1_0.image,bd1_0.issue_date,bd1_0.price,bd1_0.publish_date,bd1_0.return_date,bd1_0.subtitle,bd1_0.synposis from book_details bd1_0 where bd1_0.user_roll_no=?
2024-09-28T20:27:58.005+05:30 DEBUG 6724 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, application/xhtml+xml, image/avif, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8, application/signed-exchange;v=b3;q=0.7]
2024-09-28T20:27:58.009+05:30 DEBUG 6724 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed 200 OK
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
No description
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
This is the endpoint
@PostMapping("/deletestudentbook")
public String deleteStudentBook(@RequestParam Long roll_no, Long book_id, Model model) {
log.debug("Received request to delete student book. roll_no: {}, book_id: {}", roll_no, book_id);

StudentDetailsDto studentDetails = studentDetailsService.getStudentById(roll_no)
.orElseThrow(() -> {
log.error("Student not found for roll_no: {}", roll_no);
return new StudentNotFound("No Student Found");
});

model.addAttribute("studentAllBooks", studentDetails);

if (studentDetails.getBooksDetails().size() == 1) {
log.debug("Deleting student books and details. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(roll_no, book_id);
studentDetailsService.deleteStudentDetails(roll_no);
return "redirect:/";
} else {
log.debug("Deleting student books. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(roll_no, book_id);
return "allbooks";
}

}
}
@PostMapping("/deletestudentbook")
public String deleteStudentBook(@RequestParam Long roll_no, Long book_id, Model model) {
log.debug("Received request to delete student book. roll_no: {}, book_id: {}", roll_no, book_id);

StudentDetailsDto studentDetails = studentDetailsService.getStudentById(roll_no)
.orElseThrow(() -> {
log.error("Student not found for roll_no: {}", roll_no);
return new StudentNotFound("No Student Found");
});

model.addAttribute("studentAllBooks", studentDetails);

if (studentDetails.getBooksDetails().size() == 1) {
log.debug("Deleting student books and details. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(roll_no, book_id);
studentDetailsService.deleteStudentDetails(roll_no);
return "redirect:/";
} else {
log.debug("Deleting student books. roll_no: {}", roll_no);
studentDetailsService.deleteStudentBooks(roll_no, book_id);
return "allbooks";
}

}
}
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
This is the place where i was deleting it
<form th:action="@{/admin/deletestudentbook}" method="post" style="display:inline;">
<input type="hidden" name="roll_no" th:value="${studentAllBooks.roll_no}" />
<input type="hidden" name="book_id" th:value="${book.bookId}" />
<button type="submit" class="absolute top-2 right-2 text-gray-500 hover:text-red-500">
<i class="fas fa-trash-alt"></i> <!-- Dustbin Icon -->
</button>
</form>
<form th:action="@{/admin/deletestudentbook}" method="post" style="display:inline;">
<input type="hidden" name="roll_no" th:value="${studentAllBooks.roll_no}" />
<input type="hidden" name="book_id" th:value="${book.bookId}" />
<button type="submit" class="absolute top-2 right-2 text-gray-500 hover:text-red-500">
<i class="fas fa-trash-alt"></i> <!-- Dustbin Icon -->
</button>
</form>
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 9/28/2024 in #java-help
Deleting Error
No description
16 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
buddy
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
ok thanks
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
got it
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
hmm
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
package com.ShelfSpace.advice;
package com.ShelfSpace.advice;
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
package com.ShelfSpace.ShelfSpace;
package com.ShelfSpace.ShelfSpace;
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.bind.annotation.RestControllerAdvice;
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
@RestController
@RequestMapping("/api/Student")
@CrossOrigin(origins = "http://localhost:3000")
public class RestApplication {

@Autowired
private StudentDetailsService detailsService;
@PostMapping("/addBook/{roll_no}")
public ResponseEntity<?> addBooksToStudent(@RequestBody BooksDetailsDto booksDetailsDto,
@PathVariable Long roll_no) {

Optional<BooksDetails> studentBook = detailsService.addBooks(booksDetailsDto, roll_no);
if (studentBook.isPresent()) {
return ResponseEntity.ok(studentBook.get()); // Return the added book
} else {
return ResponseEntity.badRequest().build(); // Return a 400 Bad Request if the book could not be added
}

}
}
@RestController
@RequestMapping("/api/Student")
@CrossOrigin(origins = "http://localhost:3000")
public class RestApplication {

@Autowired
private StudentDetailsService detailsService;
@PostMapping("/addBook/{roll_no}")
public ResponseEntity<?> addBooksToStudent(@RequestBody BooksDetailsDto booksDetailsDto,
@PathVariable Long roll_no) {

Optional<BooksDetails> studentBook = detailsService.addBooks(booksDetailsDto, roll_no);
if (studentBook.isPresent()) {
return ResponseEntity.ok(studentBook.get()); // Return the added book
} else {
return ResponseEntity.badRequest().build(); // Return a 400 Bad Request if the book could not be added
}

}
}
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
yehh sure
46 replies
JCHJava Community | Help. Code. Learn.
Created by Danix on 8/11/2024 in #java-help
Getting 500 error instead of 400 and 409
A RestController as u can see in the code as well
46 replies