Claude Moore

Bartender
+ Follow
since Jun 24, 2005
Claude likes ...
IBM DB2 Java Netbeans IDE Spring
Forum Moderator
Italy
Cows and Likes
Cows
Total received
38
In last 30 days
0
Total given
11
Likes
Total received
120
Received in last 30 days
1
Total given
272
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Claude Moore

I would focus on the raised exception: as far as I know, Comparison methods violates its general contract means that your comparator methods violates transitive equality. I find suspect that you are testing for dTmp  > 1 to return +1, shouldn't you test for dTmp > 0  instead?
2 weeks ago
Some times ago, I had to deal with about a dozen of REST endpoint ,with a number of fields to be handled (let's say at least 30 / 40 fields each). None of these endpoint required a direct insert into a DBMS -  the json object indeed was used to construct some domain objects, and then discarded - but as I needed to log the requested I received, I decided to register each REST call payload on a SQL table.
To achieve this, I used an approach similar to the one Paul suggested, but with a support DB table mapping each json property to  a given column of a specific log table.
For example:

RESTEndpointJSONpropertyLOGTableLOGTableColumnNameSequence
RESTService1callerIDTable1CALLER_ID1
RESTService1productNameTable1ProductID2
RESTService1priceTable1PRICE3


This way, and adding more info in the mapping table structure, I was able to control actual type of each JSon property, the sequence of the field as parameter for the underlaying PreparedStatement used to log the data (which is NOT guaranteeded, you can always rely on a specific sequence of properties of a Json structure) and so on.

Of course, the time spent to build all the machinery needed to handle a similar approach is justified if you don't need to work with a single REST.

Hope it helps.

EDIT: I forgot to specify that the actual PreparedStatement was built on the fly given the info  stored into my  definition table.
2 weeks ago
My personal taste: constructors, factory static methods, public methods, then protected / private ones. It helps me to verify at a glance if I'm not breaking encapsulation (for example exposing too many methods as public)
2 weeks ago
I'm really happy, this book is about a fundamental aspect of Spring that absolutely deserves to be studied (and applied) well.
3 weeks ago
Ok, done some tests: please consider following code:



What makes the difference is that the first method is handled directly by Spring, which return a quite complex response with a full trace of the validation error. Using a service, when validation isn't satisfied an exception is thrown, which is in turn returned to the caller as a much simpler JSON response.
So, which approach is best ? I'd vote for putting the validation logic in a @Service, if present: this way, one could catch the exception and handle it the way he prefers.
1 month ago
Glad you solved, anyway sounds strange that using @Validated on a Service will cause the returning json to be modified.
Could you post some code excerpt ?
1 month ago
In Spring Boot  you could annotate with @Validated your @Service class to get all @Valid annotated params in methods to be validated.
1 month ago
Glad you solved your problem with another JDBC driver, anyway it's really weird that Microsoft driver doesn't work, while another vendor's does not.
If you can, could provide exactly which SQL server you are connecting to, from which java runtime, and from which OS?
I think it would be interesting to keep track here, on the ranch, of a similar issue.Who knows, maybe it may be useful for someone else.
Have you tried to just copy and paste a simple sample provided by Microsoft in it's JDBC and SQL server web page ? Check both the URL and some details (like a property called integratedsecurity I haven't seen in your example).
Generally speaking, you should try to verify that a minimal example runs without issues, before attempting more complex code.
Did you check if you are using the correct msqlserver driver? I've just remembered that you need to use the correct driver version - with respect to sql server version And with respect to Java version you are using. I've got some problem using jdk 8 with a driver targeted to jdk 7.

David-kodi Weber wrote:

Claude Moore wrote:I've just checked my installation of RAD - no wizard to autogenerate REST endpoint.
However, while SOAP it's really cumbersome to implement by hand, with REST you have to place a couple of annotations on the methods you want to expose as services.
I'd do that by hand, or, maybe, I'd write my own tool to mangle the source code.





Thanks for your answer.
What are you doing after configure the annotations? How do you "create" the REST web service itself?

P.S: What version of RAD are you using? Maybe in newer versions it's possible?



Well, generally speaking, I prefer to define a REST endpoint as an annotated POJO whose methods use, in turn, some business logic classes / DAOs.
You're asking specifically about RAD so I guess you're using websphere as appserver, i.e you are working on a Java EE environment. You could expose EJBs 3.0 as RESt endpoint, without much effort and without a particular wiring; when using a POJo as endpoint, you need to register it as resource - sorry, don't have at hand and example right now.
My RAD Version is 9, don't know if more recent versions offer support for rest wizardry.
1 month ago
I've just checked my installation of RAD - no wizard to autogenerate REST endpoint.
However, while SOAP it's really cumbersome to implement by hand, with REST you have to place a couple of annotations on the methods you want to expose as services.
I'd do that by hand, or, maybe, I'd write my own tool to mangle the source code.


1 month ago
I would try to pass the credentials as properties in the proper connection method.Also, please check if SSL is required to establish a connection or not.
Little hint :you need to iterate over your cursor...
Chrome removed support for applet plugin years ago, as well as recent IE / Firefox versions.
If you really need to use an applet you need to run it via appletviewer.