Alejandro Barrero

Ranch Hand
+ Follow
since Aug 01, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alejandro Barrero

My apologies, I was looking at the wrong database.
I have the following class:

The code runs correctly executing may SQL statements.
The problem is that executing "stmt.executeUpdate(sql);" in method main I get the error "java.sql.SQLException: PRIMARY KEY must be unique". However table "document" has no rows. I just can't understand.
Thank you very much; however, this code  has been working for years and it was working las week. Well, it looks bad and I will eliminate it any way.
I have the following test Class:

My problem is that the code was working a week ago, but now i am getting java.lang.NullPointerException in  Class Stmt in package org.sqlite at lin6 of method main  and line 121 in executeQuery. Method connect appears to work correctly and I still have the database in the same path.
I don't remember changing anything.
I started creating an application from a book; it started running fine after I created the application with ng new; however after I changed app.component.ts and app.component.html I keep getting the same result in the browser no matter how many times I run   ng serve.
4 months ago
Unfortunately I cannot display images, so I have to type the structure of the application
Paperless Office
   src
       com.help.utils
       com.orm
       ....
       com.resources
           action_add.gif
           ...
           arrow_top.gif
           ...
   bin
       com
           help
           ....
           resources
               action_add.gif
               ...
               arrow_top.gif
               ...


5 months ago
I have been using this code for years

But suddenly getClass().getResource("/com/resources/arrow_top.gif") is giving me a null value. I have no idea what I have done wrong with the application. If worse comes to worse, I can rewrite the codes in several ways, but there are hundreds of lines; I wish I could find a solution.
5 months ago
My apologies for taking your time. I don't have to convert the JSON  string; the following client code works fine
5 months ago
Thanks for the replies. I was trying plain JSON at the beginning but had difficulties. GSON constructs the string i want to return correctly; the problem is that I cannot construct the Java ArrayList or array, please tell me how to do it.
5 months ago
I have the following REST controller

Without

The code runs fine in the debugger and executes fine with Posman. However, with this addition I am getting the error
java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $
at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:351) ~[gson-2.8.6.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80) ~[gson-2.8.6.jar:na]
at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.6.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:932) ~[gson-2.8.6.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:897) ~[gson-2.8.6.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:846) ~[gson-2.8.6.jar:na]
at com.paperless.controler.PaperlessController.objects(PaperlessController.java:67) ~[classes/:na]
What I am trying to do is create the code for the client, but I am getting this error.
5 months ago
Using @RestController didn't make any difference.
6 months ago
I am getting the following exception

The client code is

The controller is

In the debugger the controller is working fine.
Initially I had the same problem returning an ArrayList, so I changed the code to return an array. Currently I want to return a String; I will represent every object by a JSON string and I will write the JSON strings in the return String separated by new lines '\n'.  I still don't see a way to convert Java objects to JSON strings and how to construct Java objects from JSON Strings.
6 months ago
I am trying to access a REST controller with a Java client. The code in the controller is

The controller works with Postman although at the end posts an Internal Server Error.
The code of the client is
6 months ago
Thanks for your quick response Rob and Dave. Originally I wasn't passing the connection; I wanted to return a ResultSet, but it doesn't work after the connection is closed. It appears I have to construct the list of objects from the ResultSet and return the list.
6 months ago
I have a Spring Boot application trying to access a REST web service with RestTemplate.
The code in the client is:

The code in the controller is:

The problem is that i am getting the exception
Exception in thread "main" org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 : [{"timestamp":"2020-08-25T19:30:13.149+00:00","status":500,"error":"Internal Server Error","message":"","path":"/resultSet/com.paperless.Select_Conn@4044fb95"}]
Digging in the debugger, it appears that the program is trying to do some JSON mapping, but that is just something I have noticed. I am an experienced Java developer, but I am learning how to program REST clients. I have spend the last two days browsing the net without success.
6 months ago