This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

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 problem is with code that was working before:


I am geting the message: "CachedRowSetImpl cannot be resolved to a type". I dont know why I lost the jar file, but I was able to down load com.sun.rowset with CachedRowSetImpl.class. I was able to set the jar file at libraries at "Java Build Pat" and everything shows in Package Explorer at Referenced Libraries. I cannot understand what is going wrong?
3 months ago
No I can see the source code. What I cannot see is the tab that shows graphically the class presentation.
4 months ago
I canot longer open a Java class file with the option to see the page with two tabs at the bottom one for the code and the other to view the structure.
4 months ago
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.
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
               ...


1 year 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.
1 year ago
My apologies for taking your time. I don't have to convert the JSON  string; the following client code works fine
1 year 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.
1 year 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.
1 year ago
Using @RestController didn't make any difference.
1 year 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.
1 year ago