Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!

Ron McLeod

+ Follow
since Feb 12, 2013
Ron likes ...
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
Forum Moderator
Ron McLeod currently moderates these forums:
Richmond, BC, Canada
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ron McLeod

Lisa Austin wrote:For whatever reason I end with the September instead of August as the month.   I don't know how this is happening.  Can someone please tell me why I'm receiving September instead of August?

Look here: Calendar#MONTH
17 hours ago
Do you still see the error if an initial capacity is not specified?:

    List<String> glist = new ArrayList<>();
22 hours ago
The grouping and decimal separators matter as well.  Ecuador and Canada-French use the dollar symbol, but comma as the decimal separator and period as the grouping separator.  Probably other locales do as well.

Jack Tauson wrote:Since I have to define database connections where I would be calling a stored procedure and passing the JSON related information to the Stored procedure or maybe the object to the stored procedure.

Rather than storing the JSON representation or a Java object in the database (or passing to a stored procedure), you should just use the fields in the Person class.  For example:
Also, do you really need a stored procedure?

Jack Tauson wrote:Is it a good idea to have getter and setter methods just like it's there in the `Person` class in the example code that I am referring to?

If you want to implement a RESTful-style Web Service API, then you should be thinking of transferring representations of the Persons between the client application and the server, using the various HTTP methods to indicate your intention, and the HTTP status codes to indicate the success/failure of the request.  For example:

POST /api/person
    - create a new Person on the server
    - client provides represenation of Person
    - server provides unique identifier (URI) for newly created Person

GET /api/person/{person-id}
    - get an existing Person from the server
    - server provides represenation of Person

PUT /api/person/{person-id}
    - replace an existing Person on the server
    - client provides represenation of Person

PATCH /api/person/{person-id}
    - update a portion of existing Person on the server
    - client provides partial represenation of Person

DELETE /api/person/{person-id}
    - delete a Person from the server

Jack Tauson wrote:In which file I should consider defining database connections from design point of view? I mean is it better to define it in `` Or `` or `` ?

It really shouldn't be part of the WS application, resource, or entity.  You should have a Data layer which deals with interfaces with the storage.  For example:

1 week ago
If you are going to use the structure in the example, you will need to configure your IDE with two java source locations: src/main/java, and src/test/java.

For example - with Eclipse, it would look something like this:

1 week ago
Are the two classes in the same package?
1 week ago

Vijitha Kumara wrote:And one approach to manage your tests would be put the test Classes in a similar package as with the source but under the test directory.

Sam Parson wrote:Hmm, I thought package == directory?

What Vijitha is saying is to put the application code and the test code in the same package; then you can take advantage of package-private access to peek inside or mock settings with the class under test.

Here's an example - MyApp and MyAppTest have the same package (com.example), but different directories:

└── src
    ├── main
    │   └── java
    │       └── com
    │           └── example
    │               └──
    └── test
        └── java
            └── com
                └── example
1 week ago

Jack Tauson wrote:I deployed the WAR and POSTMAN is still throwing same error. Not sure why this is happening.

What do the server logs tell you?

Which server are you using?
1 week ago
Also, take a look at your server logs -- they might show you the endpoints.  Here's an example with Tomcat/Tomee:
1 week ago
Confirm that the name of the war file that you are deploying is actually JAX-RS_PostExample.war.
1 week ago
What is the name of your project - JAX-RS_PostExample or JAX-RS_examples?

The example you refer to uses URI: http://localhost:8080/JAX-RS_examples/rest/HelloWorld/writePersonToDB, but in Postman, you are using URI: http://localhost:8080/JAX-RS_PostExample/rest/HelloWorld/writePersonToDB
1 week ago
And with bash ...
1 week ago
I don't think you can use newline as a parameter with Command Shell.  You can however with Power Shell ....
1 week ago