i hate SQL so much its unreal
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 2/19/2025 in #java-help
whats the point of OOP encapsulation?
hey guys. i was wondering if smb could help me out? im tired of reading countless articles that are copy pasted from each other so maybe a person and not a bot can explain stuff to me. in all the textbooks its said that "muh encapsulashun" is data hiding (whatever that means), using private fields, getters and setters. so now i have some questions:
1. who are we hiding the data from? lets say i have this:
so? from who i need to hide the "data"?
2. lets say i want to hide "data", shouldnt i put it somewhere more safe? i.e. database, vault, etc?
3. whats the point of having private fields if u can just call the getter/setter?
book.author
is the same as book.getAuthor()
. so why overcomplicate everything?
thanks in advance. im trying to understand whats the point of this stuff.8 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 2/19/2025 in #java-help
how does open-closed principle really work?
hey guys. i have a question an id like to hear other opinions. lets say i have this.:
it works fine. but then there comes a point when i need to check if the car is
Yellow
and Blue
. then it means i have to add more if statements:
now the questions arise:
1. is adding more if statements considered to be extension
or modification
? In my understanding its both. You modify code all the time. You changed variable name? Its modification. In Cambridge dictionary modification
is described as a change to something
. Refactoring is modification too. You cant write excellent code from the first try.
2. does the first and second pieces of code follow open-closed
principle? why?24 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 2/7/2025 in #java-help
can request be validated before reaching the controller?
hey guys. im talking with a friend of mine and he mentioned that in php language you usually validate the data BEFORE it reaches the controller. i was wondering if this can be done in Java Spring app? as i understand this idea cant be done in Java Spring app. the controller in Spring app is the entry point to the application. and you cant really do much in Dispatcher servlet. what do you guys think? thanks in advance.
16 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 1/22/2025 in #java-help
why my spring app cant connect to DB?
hi guys. im using intellij idea to run my java spring app. i connected my db to the intellij idea.
im using ssh tunnel to connect to database. when i test the connection everything is fine. but the problem arises when i try to start my java spring app.
in
application.yaml
i have this piece of configuration:
and when i start the app i get
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
whats wrong? can smb help me out pls? thanks in advance7 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 1/22/2025 in #java-help
why do i get redirected to /login?
hey guys. i have java spring app. it has this websecurity config chain:
1. when i launch my app on computer, my endpoints are called fine.
2. when i deploy my app to the server, the endpoints arent being called - i get 404
i have nginx on the server. i opened nginx access log:
i dont understand why its being redirected to
/login
. can smb help me out? as i understand its smth with nginx, not the java app itself.23 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 11/26/2024 in #java-help
can smb explain what is the difference between bitwise and logical operators?
i dont understand at all. and the more i google the less i get it.
12 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 11/4/2024 in #java-help
how to properly config my application logging?
hey guys. i have java spring app. and on the server its running as a service. heres my
application123.service
:
Now when this service runs on the server, everything is logged to syslog. And the thing is that id want to log everything to separate file. smth like application123.log
. so my question is should i edit my application123.service
file, or should i edit application.yaml
file? thanks8 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 10/14/2024 in #java-help
Soap request gives me 404 and "No endpoint mapping" even if everything is correct
Hello everyone. Its been almost a week and I still cant find an error and the reason why I am getting this kind of error. The thing is that my endpoint is correct, everything is set up fine. Earlier this endpoint had different name and everything worked fine. And now after changing the endpoint name everything just broke.
Things I tried: asking chat gpt and gemini, asking for help on different discord servers, googling and browsing stackoverflow.
The thing is that I cannot change the request body and I just need to use this request body.
This is my Java code: https://pastecode.io/s/antg289v
xsd and wsdl: https://pastecode.io/s/7142nmnr
request body: https://pastecode.io/s/ng61346m
console log: https://pastecode.io/s/1wg2oi2f
Could somebody take a look and help me out? Huge thanks
6 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 10/9/2024 in #java-help
No endpoint mapping found for [SaajSoapMessage idcheck]
hi guys. im developing soap service in java spring and i keep getting
No endpoint mapping found for [SaajSoapMessage idcheck]
erro. can smb pls help me out?
My java code: https://pastecode.io/s/antg289v
xsd and wsdl: https://pastecode.io/s/7142nmnr
request body: https://pastecode.io/s/ng61346m
thanks alot5 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 10/7/2024 in #java-help
java variables need to have the same name like in SOAP request?
hi guys. i have soap service in java spring. i have this dto class:
i send this request body:
but i get:
i noticed that if i name my java vars the same like they are named in request xml, everything is fine. But the thing is that my code gets messy. Is there a fix for this scenario?
4 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 10/7/2024 in #java-help
soap request give me 400 bad request
hi guys. i have soap service in java spring. i have this dto class:
i send this request body:
but i just get 400 bad request. can smb help me out? chatgpt doesnt help at all
9 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 10/3/2024 in #java-help
how to find WSDL file location in my SOAP webservice?
hey guys. i have soap webservice that is running on my server. i can call it with postman:
http://dev.mycompany.lt/bgw/perlas
then i add needed body and receive expected response. everythings fine. but i was wondering what is the location of my wsdl file? can smb help me out? thx8 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/27/2024 in #java-help
WebSecurityConfig in java spring app doesnt work
hey guys. can smb help me out? i have java spring app runing on my server
dev2
. on the server i also have nginx basic auth and proxy configured. now when i do the request to http://dev2.mysite.lt/bgw/perlas
i get asked for my nginx basic auth credentials. i enter them, and later im prompted with another login page thats comming from my app. my WebSecurityConfig
looks like this:
can smb help me out? thx6 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/24/2024 in #java-help
what password to enter when doing git push?
hey guys. can smb help me out with git? I tried googling but theres no normal and simple answer. the more i read the less i understand.
i did
git commit -m "my message"
.
then when i try to do git push
i get:
what password do i need to enter? can smb explain?63 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/23/2024 in #java-help
how to enable basic auth in java spring app?
hey guys. i have java spring app. in
WebSecurityConfig
i have this:
and i want to enable basic auth. i know that i can do it in nginx, but i was wondering if i can do it in my spring app config somehow. can smb help me out? thx8 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/16/2024 in #java-help
how to test my scheduled methods locally?
hey guys. so i have java spring app. in the app i have a 2 methods annotated with
@Scheduled
and each method has 2 cron expressions (one for work days, one for weekend). i deploy my app to the server. and on the same server i have cron jobs and thats how my code is being scheduled. but my question is how to locally test if my cron jobs for these two methods work fine?4 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/16/2024 in #java-help
how to properly update spring version?
hi guys. i have java project and current spring version is
2.2.6
. i need to update the version to the newest. as i understand its 3.3.3
. so i have a couple of questions;
1. since i use gradle, i just need to change the version here?
2. is there smth to look out for when updating spring version in my project?
thanks in advance5 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/12/2024 in #java-help
how to return multiple objects in SOAP webservice?
hey guys. im developing SOAP webservice in java and i have a question. there are two operations
checkId
and createSale
. and there are CheckIdRequestDTO
, CheckIdResponseDTO
, CreateSaleRequestDTO
, CreateSaleResponseDTO
. when validating checkId
request and there are some errors, i set needed CheckIdResponseDTO
fields to needed values and return the DTO and everything is fine. so my endpoint returns CheckIdResponseDTO
in both cases: if its ok, or theres an error. But now im having trouble with createSale
request. im validating CreateSaleRequestDTO
, and if theres an error i dont have anything to return. I was thinking about constructing something like CreateSaleRequestErrorDTO
. but then my endpoint cant return it. this is my endpoint so far:
and idk what to do in this situation. can smb help me out? thx9 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 9/12/2024 in #java-help
what data type to use for storing ids?
hi guys. in java code i will need to use/store ids, that look like
11000000035
. what data type to use? long
or just String
? because int
in my case doesnt have enough storage for symbols. thanks12 replies
JCHJava Community | Help. Code. Learn.
•Created by i hate SQL so much its unreal on 8/16/2024 in #java-help
exception handling in SOAP webservices
hey guys. i have a question about SOAP webservice. i have this piece of code in my service layer:
and i have this exception:
and the exception is later handled by the
RestResponseEntityExceptionHandler
.
so i have a couple of questions:
1. can i use the same exception? or do i need to create a duplicate one that will only be used for SOAP service? can i reuse the exception from my REST service?
2. how to handle the exceptions in SOAP webservices? i tried googling but honestly didnt understand a thing.
can smb help me out? thx4 replies