I have a spring boot app that connects fine to my PostgreSQL server running locally in Desktop Docker. Than I wrote a simple Dockerfile to run my app in container. Container starts but can’t connect to my db server with error message: Connection to localhost:5432 refused. Why and how to fix this? Answer…
Tag: java
How do I store tokens into their own element in a given array?
I am trying to write a method that will use StringTokenizer to break up a user inputted String by a single space and store each word into their own array. The given code is as far I have gotten before getting stuck for 3 hours. I am trying to test out the code by having the for loop print out
Converting Long bitwise operations to BitSet bitwise operations
I’m trying to convert my code from using bitwise operations on Long type to the same operations on a BitSet, but I can’t find the right syntax. This is the original code: And this how I try to convert to BitSet: I can’t find the right syntax for this line: I did manage to use the and syntax …
How to split a string by a newline and a fixed number of tabs like “nt” in Java?
My input string is the following: My intended result is dir, subdir1, subdir2nttfile.ext The requirement is to split the input by “nt” but not “ntt”. A simple try of also splits “tfile.ext” from the last entry. Is there a simple regular expression to solve the problem? Than…
Fragment Inside a Fragment Not Working with ScrollView
When I am Using Fragment Inside a Fragment with ScrollView It is not working. In My Case the FirstFragment is fine. the fragment that is inside is not showing in full screen and lot of contents in BooksFragment are disappear this is My FirstFragment ‘s XML : </androidx.constraintlayout.widget.Constra…
org.everit.json.schema.SchemaException: #: could not determine version
A SchemaException gets thrown saying the version could not be determined as the title says. The schema version is clearly in the schema. This is all before data validation. Any ideas why this error gets thrown? My schema is as follows: Answer The library doesn’t support draft 2020-12 and 2019-09. You wi…
Couldn’t implement binary search on linked list
i am a cse student who takes data structures course. Trying to implement binary search algorithm to my SinglyLinkedList class, somehow i’ve failed. Could you check it what’s wrong please ? The related method; I’ve debugged and it just enters the loops this side: else if(temp.getElement() >…
How to use Bearer or Apikey keywords automatically onswagger java
I am trying to make some security configurations in my SwaggerConfiguration class. My purpose is sending scheme keyword with authentication key like or It is possible on ASP.NET Core but I can only achieve this in Java like this: What shall I use for my Docket security scheme instead of ApiKey? Answer You can…
Hibernate how to commit transaction even when exception pops up
i have a method in Service A And another method in Service B My problem is that when “repository.insertRandomValue()” throws ConstraintViolationException for example, then even tho it was caught in catch(), the thread ends with I have tried setting the propagation to REQUIRES_NEW and tried to set …
How can I get a FileChooser to populate a TextView during a TableRow creation?
Problem: I’m having trouble getting a FileChooser class to populate a TextView during a TableRow creation. I receiving a Invocation Exception in the Android created “looper.java” which appears to be caused by a variable tagTrace=0 being read as “!=0”. So, I’m not sure how I…