it’s again about VSCode and Java (I start learning it). I have a little test program that loads images and works fine when started in the VSCode IDE. I have also seen here that I must somehow load the pics from a “classpath” – so I added a classpath for the “pics” folder shown in the screenshot. I see that
How do I extract exact value from Json
Below Json I want to get only first mail value (abc@test.com) using java. Please anybody can suggest how do I extract exact value from below Json. Thanks in advance. Answer as they have already said json standard doesn’t impose ordering, so be careful
How to properly use Postgres-style url in Spring Boot application.yml
I’m trying to figure out if there is a way to configure Spring datasource using a single string that contains all credentials: By far I see that spring.datasource always requires username and password properties to be defined separately and url property to start with jdbc:. Is there some other way to configure DB connection and use Postgres single string url?
Regex match any of the words separated by slashes
I need to develop a validation pattern for catching any kind from: pdf/csv/xlsx select any separate word is simple: (pdf|csv|xlsx). However, I need to check that any combination with them separated by slash is fine as well. For example, correct flow: Incorrect: Answer You may use this regex: RegEx Demo
Handling a custom exception without changing the test class (java)
I need to throw a couple times a custom exception. A test class is checking if my solution works but I’m not allowed to make any changes to this class which leads me to my problem. I simplified the problem here, because the whole code is not needed here Answer I have found the solution for my problem. In my
How to save generated pdf as blob in Java
In my Spring Boot app, I am generating pdf file from html string and save it a temp location by using the following approach: At this point, I want to save the generated pdf as blob and return it in a proper format. 1. The client will receive the blob file and then open it as pdf. In this case
Error while getting sql record using EntityManager
I am using EntityManager in spring boot app to get result from this query Its giving me correct output in PgAdmin but in java code List resultList = em.createNativeQuery(str).setParameter(1, sectionId ).getResultList(); Giving error ERROR: syntax error at or near “:” its breaking at data::jsonb .How do handle this using EntityManager. Answer You need to CAST like CAST(c.data as jsonb)->>’product_id’ from
Maven: how to find dependencies
Maybe I am misunderstanding Maven’s dependency principles but this is my question: I have a little Java program that requires these imports Now instead of importing these at the top of the code, I would just go into the POM file of my Maven project and add the dependencies. But on https://mvnrepository.com/ how do I find the correct imports? Is
Difference between generating UUID in Java and MySQL
I need to insert random id into one table and add that id to another table as foreign key. So I am not sure how to save UUID() if I generated it in MySQL but if I generate it in Java I can just save it into a variable. I wonder are there any drawbacks if I generate it in
Type Inference Algorithm
Why inference determines that the second argument being passed to the pick method is of type Serializable ? Why s compiles but s1 line doesnt compile Answer Because the result and both arguments must be the same type – the T. In the second example, the result is a String, first parameter is a String, but the second argument is