Samantha Rupasingha

Greenhorn
+ Follow
since Jan 26, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Samantha Rupasingha

I am working on a small project but very important one for school, and I want to link my public database to the software using jdbc. I am getting connection error to the database!

I have started my project in localhost and it worked just fine.

PS: I am using, also, mysql-connector-java-8.0.15.jar and Hibernate.

I am using this method for the connection:



I can't show you the host ofc but I'll provide the format that I used and I am sure that it is the correct format.


I am excepting a normal connection to the database but, unfortunately, I can't!
5 months ago
Well, I'm working on a library where I need to create a JPA reference of some serialized entity objects.

The time I need to create the entity reference I don't have the ID field value so I somehow first need to create the proxy and then set the id. So I cannot use the


Do you guys have any suggestions?
5 months ago


I am expecting a large json data in my request. And I need to parse that in java. I need to decide the json structure based on the parsing performance. Below are 2 json structure:

   Json Object

   Json Array

Thanks in advance
5 months ago
I have a matrix that represents a grid and would like to find out all possible places an object can move to.

An object can only move horizontally or vertically.

Let's assume that the example below is the grid I'm looking at, which is represented as a 2d matrix. The object is the *, the 0s are empty spaces that an object can move to, and the 1s are walls which the object cannot jump over or go on to.

What is the best way to find all possible movements of this object provided that it can only move horizontally or vertically?

I'd like to print a message saying: "There are 9 places the object can go to." The 9 is for the example below, but I would like it to work for any configuration of the below grid. So all I have to do is give the current coordinates of the * and it will give me the number of possible positions it can move to.

A thing to note is that the *'s original position is not considered in the calculations, which is why for the example below the message would print 9 and not 10.

I have a isaWall method that tells me if the cell is a wall or not. The isaWall method is in a Cell class. Each cell is represented by its coordinates. I looked into using Algorithms like BFS or DFS, but I didn't quite understand how to implement them in this case, as I am not too familiar with the algorithms. I thought of using the Cells as nodes of the graph, but wasn't too sure how to traverse the graph because from the examples I saw online of BFS and DFS, you would usually have a destination node and source node (the source being the position of the *), but I don't really have a destination node in this case. I would really appreciate some help.

5 months ago
I'm trying to verify if all the elements in an array list are same or not. This is my code:

5 months ago
I am building chat application and I want a table - chats and another - messages. Chat will have many messages, also id and user_first and user_second. Right now I am doing it with a composite primary key where the composite is user_first and user_second and the id is unique auto-increment:



is there any better way to do it and why?
I have the hql query that I am executing but receive an error that I don't really understand the cause of.

This is my code:




I get his error on the webpage when trying to execute it:



And also this console error:

5 months ago
I have 2 @RequestParam parameters in my Controller. I want to set the Required value of both the parameters based on a Condition. The condition could be like, if one of the parameter is passed, the other has to passed. So set the required of other as true and vice-versa. Otherwise set both false if none of the parameters are passed.



The syntax of using the variable name inside @RequestParam() is wrong, but I wanted to explain what I want.
5 months ago


I currently have a Many to Many relationship between Events and Users. The auto generated table in my DB called event_registrations keeps track of the relationship and which user goes to which event based on their ids.

What I want to do is have a controller method that takes in an Event id together with a list of user IDs so that the given users get removed from the given event.

Here are my model classes:




What I've tried so far in the EventController:




This runs without problems but the the entries still exist in the join table afterwards. When debugging this, the users do get deleted from the Event object but the changes don't get persisted to the database.

Any help is appreciated!
5 months ago
Simple scenario:

   1.an AdmisRejet can be linked to a Admis or a PreCandidat.
   2.Admis and PreCandidat can have many AdmisRejet.

All was working when I only had Admis and AdmisRejet.

But then I add PreCandidat (the same way as Admis), I get an hibernate error.

Can't find out why...

Model (they all have getters and setters and ids):





Error:

   Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on nc.unc.importparcoursup.dao.admisDAO.AdmisRejet.preCandidatRejet references an unknown entity: nc.unc.importparcoursup.dao.pgiCocktailDAO.entity.PreCandidat
5 months ago
Why does the below code displays new line in console, but not in the browser/database? How can I resolve this?



Please assume that this code snippet is a part of the bigger code that is saving the conversation in a database.
5 months ago


I need a little help to find the error in one of the code. For that I need a little help here. What is exactly the method definition for the function int lastIndexOf(int ch). I think lastIndexOf is a built in method in java. Thank you for the help
5 months ago
I need to create a java project with the following: I have an input file that holds calls range in milliseconds all over the year – the file is sorted by start time. for example 0-100 (call started at 0 ended at 100) 1-100 , 5-50 , 60-150, 65-180 I need to return the period in the year when the network was the busiest. in this example the result will be 65-100 because in this period there were 4 calls in the air I have limited heap memory ( 8GB ) and must run over the file only once what is the best logic to use here ( in java)
5 months ago
I need to create a java project with the following: I have an input file that holds calls range in milliseconds all over the year – the file is sorted by start time. for example 0-100 (call started at 0 ended at 100) 1-100 , 5-50 , 60-150, 65-180 I need to return the period in the year when the network was the busiest. in this example the result will be 65-100 because in this period there were 4 calls in the air I have limited heap memory ( 8GB ) and must run over the file only once what is the best logic to use here ( in java)