Posts by Filipe L. Constante • 814 points
40 posts
-
0
votes1
answer88
viewsA: Nullpointerexception when inserting java data
Well, the answer lies in the error itself. Your object "o" is null. "o. getDataCadastro(). getTime()" You need to check if the "o" object is not null and if there is data in getDataCadastro(),…
-
0
votes1
answer118
viewsA: Doubt with the Function window in Postgresql
Use it this way it’ll work: SELECT * FROM ( SELECT pais, modelo, fabricante.nome, (venda.valor - automovel.preco) AS lucro, ROW_NUMBER() OVER(PARTITION BY pais ORDER BY pais, (venda.valor -…
-
2
votes2
answers703
viewsA: Problem comparing Strings in Java during the while loop
Opa! Change the code snippet: while (nomeDaCidade != "Zimbabue de Minas") { for while (!"Zimbabue de Minas".equals(nomeDaCidade)) { Always try to use "equals" for string comparison. Note that I…
javaanswered Filipe L. Constante 814 -
4
votes2
answers88
viewsA: VARCHAR FOR NUMBER
Well, this is described in Cast Functions and Operators The type for the result can be one of the following values: BINARY[(N)] CHAR[(N)] DATE DATETIME DECIMAL[(M[,D])] SIGNED [INTEGER] TEAM…
-
1
votes1
answer47
viewsA: Calculation in query in the Database
In your SQL, the use of ROUND is incorrect, it is rounding without decimal. Use in this way: ROUND(pacote.Quantidade * produto.Preco, 2) -- o 2 significa 2 casas decimais :) In case your SQL would…
mysqlanswered Filipe L. Constante 814 -
3
votes1
answer43
viewsA: Handling of empty fields
To replace the NULL field with a value, use ISNULL(). SELECT ISNULL(name, 'Não Encontrado') FROM bairros; Returns 'Not found' if name is NULL :) More information about this function, access official…
-
0
votes3
answers97
viewsA: I cannot save my Selectmanycheckbox Primefaces in the database
Humberto, you are trying to insert a String into a Long type object. Caused by: java.lang.Illegalargumentexception: Can not set java.lang.Long field…
-
0
votes1
answer142
viewsA: Cannibal Dinner Problem in Java
If you do not want the "serve" action to be executed at the same time then it should not be synchronized. In this case the section below must be modified by the following method:.. public…
javaanswered Filipe L. Constante 814 -
6
votes3
answers485
viewsA: Aid in SELECT DISTINCT
Use the form below: SELECT COD_CLIENTE,MAX(DT_ATUALIZACAO) FROM TABELA GROUP BY COD_CLIENTE; Depending on the situation, use MIN() instead of MAX(); I hope I’ve helped! :)…
-
0
votes0
answers23
viewsQ: Post conditional strange behavior (creating array)
Whereas I have these auxiliary classes: class HorasDisponiveis { public $diaSemana; public $horario; public $disponivel; public $confirmado; public $qtdDocas; } class FaixasDisponiveis { public…
phpasked Filipe L. Constante 814 -
1
votes4
answers2571
viewsA: Number of vowels in the Python function
Alex, follow the example below that solves your problem. def contarVogais(a): vogais = "aeuioAEUIO" result = 0 for char in a: if char in vogais: result = result + 1 return result…
-
1
votes1
answer71
viewsA: I am unable to list the data in the Mysql database using Hibernate JPA
You should pack your Query. Wrong query: return gerenciador.createQuery("from estado").getResultList(); Correct query: return gerenciador.createQuery("from Estado").getResultList(); In this case, it…
-
0
votes1
answer25
viewsA: My case 3 does not delete from the list and case 4 does not compare and returns the amount of gender written
What happens is that in your Case 3, in the stretch: System.out.print("Qual nome do livro que deseja excluir ? "); String nome = sc.nextLine(); sc.nextLine(); You call sc.nextLine() to the String…
-
1
votes1
answer644
viewsA: java.net.Bindexception: Address already in use: bind
Well, the error is saying that the WS address you are trying to use is already in use. Check your configuration and add a free port. Caused by: java.net.BindException: Address already in use: bind…
-
0
votes2
answers2455
viewsA: Build error: "Resource Leak" when using Scanner
At the end of your class main, place the call close(). input.close(); Classes using resources other than memory (in the case of Scanner) should provide ways to explicitly allocate / misalign these…
-
1
votes1
answer51
viewsA: SQL CASE command
Well, I got a Mysql here and tested, it worked: SELECT (CASE WHEN CHAR_LENGTH(description) > 5 then LEFT(description,8) else description end) AS description FROM contentphp; I hope I’ve helped!…
-
0
votes1
answer57
viewsA: Sqlite database
These two variables are not initialized, will give nullpointer. String vaiqcolanome[]; int vaiqcolaidade[];
sqliteanswered Filipe L. Constante 814 -
2
votes3
answers347
viewsA: Problem of the Year 2038
What is the bug: The bug is the ending of the 32-bit numerical sequence that is used to count time from mid-day on January 1, 1970 adopted mainly by the C language and derivatives. The maximum…
-
0
votes1
answer116
viewsA: Removing comma from the pl sql column
This way below you will get the expected result. Possibly there is another even more elegant way to be done, but this one works.. :) Table participants: Constante, Filipe | de Tal, Fulano UPDATE…
-
0
votes2
answers104
viewsA: How to return an integer when accessing an end-point?
Try it like this: Random r = new Random(); @RequestMapping(path = "/teste", method = RequestMethod.GET, produces = "text/plain") public ResponseEntity<String> teste() { Integer numero =…
-
4
votes1
answer112
viewsA: How to transform a string into an array
I think it helps you.. String teste = "345,421,888,211"; //Vou dividir a string quando encontrar o caractere "," String[] teste2 = teste.split(","); //Aqui vou percorrer o array criado e printar o…
-
1
votes1
answer31
viewsA: values in a hashmap
Hi! You can create an auxiliary method to do this for you. Follow an example: public static void main(String[] args) { String frase1 = "TECNOLOGIA ENVOLVE SERVICO RECURSOS ESTRATEGIA"; String frase2…
javaanswered Filipe L. Constante 814 -
0
votes1
answer74
viewsA: How to read a file that is inside an EAR
Try this way: URL url = SomeClassInEar.getClass().getClassLoader().getResource("/META-INF/arquivo.properties"); File file = new File(url.getPath()); FileInputStream fis = new FileInputStream(file);…
-
1
votes1
answer137
viewsQ: Maximum Execution time doesn’t work?
I need my application to stop, accuse error, "Maximum Execution time of 5 Seconds exceeded" would be ideal as long as the time is over 5 seconds for example. Researching right here in the community…
-
2
votes1
answer102
viewsA: Exception in thread "main" java.lang.Nullpointerexception - CRUD Java Mysql
This little guy is not instantiated or null. tbProduto.setModel(new ProdutoTableModel(new ProdutoDAO().listarTodos())); Install it will work! I hope I’ve helped.…
-
2
votes1
answer179
viewsA: Check whether person is of legal age, if yes delete it
First, an example of how to get a date type value in mysql. SELECT STR_TO_DATE('2019-04-15', '%Y-%m-%d'); Example of getting the difference between the dates SELECT…
-
0
votes1
answer146
viewsA: Tesseract - OCR recognition, invalid memory access
The error was due to a missing lib. I just downloaded the file "wget https://github.com/tesseract-ocr/tessdata/raw/master/eng.traineddata", I put it in the right folder and it worked. I found the…
javaanswered Filipe L. Constante 814 -
0
votes1
answer146
viewsQ: Tesseract - OCR recognition, invalid memory access
I am trying to read a license plate of a car/truck using the java Tesseract. However, I am experiencing error. I still can’t understand why. Follows: private void…
javaasked Filipe L. Constante 814 -
1
votes1
answer80
viewsA: I want to query several words independently in mysql
Try this code, I made it quick but it’s over.. <?php $comandoSql = "select id from items where descricao" ; $fraseAux = split(" ", str_replace('%', '', $frase)); for($i = 0; i <…
-
1
votes1
answer243
viewsA: Calculating Number Frequency in an Arraylist
Bruno, I made it quick here but I think it will solve... Modify the total method in your Staff class: public int totalFaltasAluno(int resultado) { int totalFaltas = 0; for(Integer item : faltas){…
javaanswered Filipe L. Constante 814 -
0
votes1
answer154
viewsA: Error for Importing JDBC from sqlServer with Maven
I went through this same problem in the past and solved it in the following way: Add the code below to your connection code: static { try {…
-
1
votes2
answers120
viewsA: Manipulation of Arraylist
Well... I commented on your code to give you a north to fix the problem, because it is quite basic. I hope that with this I can help you. public void marcarFalta(int getMatricula, int mes, int dia)…
javaanswered Filipe L. Constante 814 -
0
votes1
answer68
viewsA: How to restrict access to the Java API using Spring Security?
You can do this in several ways, I’ll give you some examples. Restrict by IP, only the Ips you set will be able to access the API, whichever is different, you reject. You can use Oauth2 as well, as…
-
0
votes1
answer77
viewsQ: Get free hour ranges with SQL only
I am creating an agenda and need to perform a consultation of the interval between scheduled times. Example: Tabela: HORARIO_ATENDIMENTO INICIO: 08:00 FIM: 18:00 Tabela: Agenda ID: 1 HORA_INICIAL:…
-
1
votes1
answer49
viewsA: Array in PHP str_replace
So as a suggestion, and also for ease of reading, I suggest you replace "_" with or #1, #2, #3... and then just replace the information Follow the codes with the two examples. <?php $texto =…
phpanswered Filipe L. Constante 814 -
0
votes2
answers73
viewsA: String handling - how to separate decimal number of text in the string?
Just use the function explodes as below. Note that an array has been returned, so you know the position you need to recover. I hope I’ve helped. <?php $host = '192.168.0.24'; $execPing =…
-
0
votes1
answer2984
viewsA: Oracle sql - Expression not found
Well, without checking the structure of the tables involved is difficult, but from what I read and understood, it should stay like this: SELECT INITCAP(CD.NOME) FROM CD INNER JOIN GRAVADORA ON…
-
1
votes1
answer32
viewsA: Save application shutdown mode
Hello! There are N ways to do this, I’ll give you a few tips. If you have communication with the database via application, you can do something very simple that is a ping. You record from time to…
c#answered Filipe L. Constante 814 -
1
votes1
answer51
viewsA: How do I make an AND in PHP and run it in mysql
Your query has to be a string, it won’t conflict with PHP. Take a look at the example below. I suggest searching on the subject. <?php $servername = "localhost"; $username = "username"; $password…
phpanswered Filipe L. Constante 814 -
1
votes1
answer111
viewsA: Application error using vector java.lang.Nullpointerexception
Check the null pointer on line 25. That’s it. You need to instantiate the variable s, guy: s[i] = new Student(); Remember that in your class Student there is no constructor without the parameters,…