I’m using Java 8, Spring Boot, and PostgreSQL. I have the following query and it is giving me an error PSQLException: ERROR: syntax error at or near “.” I can’t seem to figure out what is causing this. It does not appear to be any reserved words. Edit So I turned on debug logs and got …
Tag: spring-boot
How to handle UnsupportedMediaTypeException in Spring Boot?
Hello I’m trying to call API by using Webclient in spring boot. But I’m having some issue. Although the response I requested is a json response, the server gives me an xml response when server error occur. So I am getting UnsupportedMediaTypeException error when server error occur. Therefore I wou…
How to resolve Java.lang.numberformatexception: empty string
I have a utility function which convert parseDouble value to string. I have tried with (o!=null && !isEmpty(o)) and (o!=”” && o!=null) but it is still throwing same error. Transaction amount which is processing this utility function contains empty value. Answer Firstly I don’…
Spring boot application is not getting installed when 2 jvm are running on Unix server
I have 2 application both are connected to DB2 using jndi and are installed on same jboss location but on different JVM. both are having different jndi name as well but it’s connected to same db and same user. While starting server if one app is up, we are unable to install 2nd application. Can this be …
add a dynamic column to an entity without saving it to the table
I have a model class like the following: And the method in a controller to show the output: It does show an output everythin is just fine: And I want to calculate each companies rating while showing data to the end user. So the output should be as follows: Is it posible to add the rating column dynamicly to t…
BeanCreationException when creating Bean of type org.springframework.web.servlet.LocaleResolver
I’m trying to apply internationalization in a Spring Boot app by following some guide. For some reason, in the guide that I’m following it works but not on my local. I can’t figure out why. The error I am getting in console is : org.springframework.beans.factory.BeanCreationException: Error …
JPA SpringBoot – Unable to Save New Entity to Database
I am attempting to add (save) a “User” to my SQL database through my Spring application (The @GetMapping requests currently work). I recently added the two annotations @CreationTimeStamp and @UpdateTimeStamp in my entity class…the version without those two annotations would produce the same …
Mockito:: Unit test case for JsonProcessingException when passing object
I have a class as shown below: Now I am trying to write a unit test case for this where I can throw exception and unit test the catch clause using Mockito but I am not able to mock it. I have noticed that object mapper class internally converting everything to string even if I set name and age to
What is a good way to handle an Optional object returned by a Spring Data JPA repository in a situation like this?
I am working on a Spring Boot application. Into a service class I have this service method: As usual it is calling the Spring Data JPA findById() method returning an Optional object. I am returning the User object. And here I have the following doubt: if the Optional is empty, it is throwing an exception when…
Check String against list of characters and replace it dynamically – Regex
I’m trying to find a solution for this matter. I have list of characters that needs to be replaced with particular character that is mapped with the original character. Ex : I have character map which hold the characters and it’s replacement value. Character Map : String that needs to be replaced …