Posts by cantoni • 6,602 points
149 posts
-
1
votes3
answers214
viewsA: Java Mergesort sorting algorithm error
The most important thing in situations like this is to know how to read the error output. It is something very simple, but in general, people ignore. First, it should be noted that the error output…
-
1
votes3
answers1821
viewsA: Encrypt/ Decrypt MYSQL/ PHP autoincrement ID
There are scenarios where obfuscating the ID can make sense. Sequential Ids can reveal much of your data set. An example is the Integrated Store, which shows the purchase ID at the end. It is a…
-
4
votes1
answer264
viewsA: Delete older duplicate data on MS SQL server
A simple approach is to use a CTE (Common Table Expression) to select the records you NAY want to delete. After that, just make a DELETE with Join CTE created to delete records. See the code below:…
-
2
votes1
answer128
viewsA: My BD search placed in a listview (Arrayadapter) returns the object address and not the content
Everything is working as you have programmed it. In your Hymns list (lstHinos), you add objects of the type Hino. Therefore, if you print this with the System.out.println, for example, you will see…
-
6
votes2
answers327
viewsA: After all, is Java a platform or a programming language?
A good analogy is to compare with Microsoft . NET. When using . NET Framework you can program in several languages: C#, VB.NET, C++. All of them are compiled to CIL (Common Intermediate Language)…
-
2
votes2
answers64
viewsA: Doubt - SQL Server Query
You can use the DATEDIFF function to perform this comparison. For this, I am considered that the Soldata field is of type DATETIME. Basically, just put this in your WHERE clause.…
-
1
votes1
answer108
viewsA: Two readers on the Australian
MFRC522 is a class, therefore, it is enough to instantiate two distinct objects of this class. Instantiating: MFRC522 LeitorRFID(SS_PIN, RST_PIN); MFRC522 LeitorRFID2(SS_PIN, RST_PIN); Using:…
-
4
votes3
answers1253
viewsA: What is Gzip? How does it improve a website?
In the same way that you "zip" files to reduce the size and send by email, Web servers can be configured to do the same with the files it sends to the client. In the end, the goal is to make a more…
-
6
votes1
answer8387
viewsA: When to use Dim and when to use Set?
Dim and Set are reserved words of some languages like Visual Basic, Vbscript and VBA (Visual Basic for Applications). The reserved word Dim is used to declare a variable. The word Set is used to…
-
5
votes2
answers150
viewsA: Is it possible to apply to different computers simultaneously performing CRUD?
Its scenario is one of the most common in software development (mainly commercial and business). Basically, it is composed of an SGDB (Database Manager System) and machines that will access this…
-
4
votes3
answers1743
viewsA: Transform Number into binary text
One option is this: (47).toString(2) The method toString, in Javascript, accepts on which basis you want to get the representation of the integer. In the above case was in base 2.…
-
4
votes4
answers364
viewsA: Different methods of creating an object
Create an object like this: new Usuario(); It implies not keeping his reference in a variable. This can be done, for example, when you just need to instantiate, call a method, not needing the object…
-
2
votes2
answers313
viewsA: Discovering the binary value in SQL Server
Using bitwise operations: CREATE FUNCTION dbo.Int2Binary (@i INT) RETURNS NVARCHAR(16) AS BEGIN RETURN CASE WHEN CONVERT(VARCHAR(16), @i & 32768 ) > 0 THEN '1' ELSE '0' END + CASE WHEN…
-
2
votes4
answers1202
viewsA: What kind of data to use for sale ID
If the sequential sale is something important for the user, then a viable and not very complex option is to create a field in the COMPANY table that will store in which sequence is the sale of the…
-
2
votes2
answers840
viewsA: How to know the number of files in a folder using Java?
You can use the interface FileFilter for that reason: File f = new File("/home/user/pasta"); File[] files = f.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return…
-
12
votes3
answers1336
viewsA: Is it ideal to use primitive types in Java?
Another important reason that should be taken into account when using or not using Boxed types (Integer, Float, etc.), also known for Wrappers, is that its classes are immutable (just like the class…
-
1
votes2
answers81
viewsA: Take a hardware variable and play in a software
whereas the condition of for (pressao>1024) is an error when typing the code here, the pressure value is being printed as 0, because you after receiving the Arduino reading, assign the value 0…
-
3
votes4
answers1605
viewsA: Turn Messagedigest MD5 into a string
There is also this option: String s="teste md5"; MessageDigest m=MessageDigest.getInstance("MD5"); m.update(s.getBytes("UTF-8"),0,s.length()); System.out.println("MD5: " + new…
-
0
votes1
answer169
viewsA: Add classes to software at runtime
This is very common in Java. JDBC drivers, for example, are loaded into memory through this type of mechanism. This is useful in situations where it is not possible to know a priori (at development…
-
3
votes2
answers553
viewsA: Know how many ports are open in Java program
The best place for this method is not within the class Porta, since, for this, you would need to pass a list of the instantiated doors for the count to be made. Note that ideally an instance of the…
-
3
votes3
answers709
views -
3
votes1
answer81
viewsA: Calendar variable updates the other when the second is updated?
Do gc1=gc2 does not copy the values of the gc2 for gc1. In doing so, you are copying the reference to gc2 for gc1. On a lower level, it means gc1 and gc2 point now to the same memory address where…
-
4
votes2
answers48
viewsA: Check in a table if a user is not registered
One way is this: SELECT * FROM usuarios USU LEFT JOIN sala_usuarios SALA ON USU.id_usuario = SALA.codigo_usuario_fk WHERE SALA.codigo_sala = 93 and USU.id_usuario is null I removed the Join with…
-
2
votes6
answers201
views -
3
votes1
answer231
viewsA: How to calculate the distance between X and Y with Intersection points
A brief response that will require certain research by the AP. Model your problem as a graph and apply the algorithm A*. The nodes of your graph are their positions (1AF...). Each edge of your graph…
-
10
votes1
answer264
viewsA: Why does the compiler create repeated . class files?
A. java file can generate multiple .class. The Java compiler (javac) generates more than one . class when there is an internal class and/or internal anonymous class, and for the latter the anonymous…
-
2
votes3
answers717
viewsA: SQL - Return zeroed records
The solution below is a small example of how this can be solved in a simple way. It is based on this answer and considers that there is a table called Numbers (or any other name) in the database. To…
-
6
votes1
answer2366
viewsA: SQL Count and sum
What you need is something like that: select count(*) total, sum(c) soma, sum(case when C = 1 THEN 1 ELSE 0 END) Tot1, sum(case when C = 2 THEN 1 ELSE 0 END) Tot2, sum(case when C = 3 THEN 1 ELSE 0…
-
0
votes4
answers739
viewsA: Is it possible to put an "IF" condition on media to Internet joins and other Where conditions in SQL Server?
One of the ways to do this is to create a String dynamically and use the Stored Procedure sp_executesql to execute the SQL that is in this string. Take an example: DECLARE @SQL NVARCHAR(4000)…
-
14
votes1
answer2988
viewsA: What is the purpose of the "/dev/null" path in some commands?
Before the technical explanation, a metaphor. Know when you send an email to a large company complaining about a product and get absolutely no response, this is the famous case where your email fell…
-
5
votes1
answer787
viewsA: How to find out if a directory is empty by the terminal?
You can use the find to find empty folders, see below: find . -type d -empty The . indicates that the search will be performed from the folder in which the command is executed. Already the type -d…
-
1
votes5
answers7513
viewsA: Reduce Log File Size
You need to backup your transaction log (ldf file) and then run a Shrink. The backup of transaction logs needs to be done in the same way as you backup the database (mdf file). If you don’t, then…
-
5
votes1
answer12434
viewsA: Doubt with checkbox value true and checked
Your doubt is related to HTML and not to JSP. Do not confuse value=true with checked. Although it may be confusing, the attribute value is not defining whether the checkbox is checked or not in the…
-
6
votes1
answer2107
viewsA: Questions with the Connectionfactory and DAO class
It means that Drivermanager has the static method called getConnection? And what does it return? A connection? Exactly. The method getConnection is static and will return a connection (an instance…
-
11
votes10
answers1739
viewsA: How to count the zeroes to the right of a number?
In the comments of the question it was suggested that the answer be given in any language. So to add an example at Groovy: Example with 7 zeros def numero = 2220002330000000 assert…
-
10
votes2
answers784
viewsA: printf in Java - What is %3d for?
The %d is used to format whole variables, basically can be used as follows: %d - formats an entire variable with how many digits there are; %4d - formats an entire variable with how many digits…
-
3
votes1
answer481
viewsA: Select Distinct returns repeated data when using Row_number
You’re right in your assumption. It’s exactly the ROW_NUMBER that is producing output that way. Note that you make a DISTINCT, but the ROW_NUMBER is producing a sequence of 1 to n records. How…
-
17
votes4
answers1512
viewsA: What is reverse engineering?
Reverse engineering is the process of, from the whole, understanding the parts, the functioning, the principles of something. It is a term that has been coined for hardware, however, is widely…
-
6
votes2
answers938
viewsA: Using hashcode as id is good practice?
Note that there is no guarantee of no collision when using hash functions. This means that different strings can produce the same integer number (this is a collision). An example is the strings…
-
4
votes1
answer191
viewsA: How to convert a String into an id or numerical data?
The method hashcode() of the String class transforms the String representation into an integer number. Example in Java: public static void main (String[] args) throws java.lang.Exception { String[]…
-
2
votes1
answer550
viewsA: Shell script function
You can solve this by making two scripts. The first one is responsible for going through the machine list and running ssh. The second contains the code of funcao1. Shell script 1 (script1.sh): for…
-
3
votes1
answer2026
viewsA: What is the use of get and set methods in a String array?
The attribute cursos is the type String[] and is declared with the modifier private. This means it is accessible only from within the class Aluno. However, you may need to access it from an instance…
-
0
votes3
answers1081
viewsA: Sort chained list with O(n*log(n) method)
Copy might not be a bad idea. O(n*log n + n) for a n sufficiently large can be considered the same as O(n*log(n)). Note, however, that Big-O notation is a very important direction, but not…
-
2
votes1
answer129
viewsA: How to use an arithmetic signal to separate one value from another in a mathematical string?
You need to do the split by the operator (+,-,*,/) and not by String operacao as shown in your code. For this, a simple approach (since you are learning), would be to check if the String contains…
-
5
votes3
answers5185
viewsA: How do I know in JAVA that the Resultset result is empty?
Another option is to use the method isBeforeFirst() also of class ResultSet. This method will return true if the cursor is before the first record and false if the cursor is in any position or if…
-
3
votes2
answers3727
viewsA: Greater and lesser number
Another option would be: import java.util.Scanner; class Ideone { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(" Tres números:"); int a =…
-
3
votes2
answers1075
viewsA: Is it bad practice to make direct paging on the front end?
Making direct front-end paging with these libraries is a bad thing practice? Why? In no way is it a bad practice. It all depends on the amount of data to be recovered from the server. This should be…
-
3
votes1
answer867
viewsA: Internet of Things and Remote Access
1) Amateur projects generally use their own network, so I understood configure the public IP and the no-ip of the modem to access remotely. But there is no implication in the security of the my…
-
9
votes3
answers4966
viewsA: What is the function of the operator "!" (exclamation)?
In Java, the operator ! is an unary operator used to invert the value of a boolean expression. Thus, if a Boolean expression is evaluated for True, the operator !, if applied to it, it will invert…
-
4
votes4
answers498
viewsA: Full byte type cast
Before answering the question itself, it is important to mention that this instruction byte b = 5 is not changing the result at all. It could have been done directly byte b = (byte)i. About the…