Posts by Anthony Accioly • 20,516 points
346 posts
-
2
votes1
answer181
viewsA: Mockito - Function that receives jsonObject return false
Your code fell into a corner case of Mockite in relation to stubbing in Spies. Link to relevant documentation Free translation Prank important when spying on real objects! Sometimes it is impossible…
-
14
votes3
answers540
viewsA: What kind of smart pointer to choose?
The auto_ptr was marked as obsolete in C++11 and removed in C++17. unique_ptr and shared_ptr are complementary. The unique_ptr only allows one pointer at a time to point to the administered resource…
-
2
votes1
answer705
viewsA: "No Persistence Provider for Entitymanager" for Hibernate 5.x
In Hibernate 5.2 o persistence Provider standard is the org.hibernate.jpa.HibernatePersistenceProvider. The preview in the ejb package was already being deprecated since version 4.3 of Hibernate…
-
7
votes2
answers257
viewsA: How to show the data repeated only once?
I believe you’re looking for the job GROUP_CONCAT: select l.id_livro, MIN(l.titulo_livro), GROUP_CONCAT(a.nome_autor), GROUP_CONCAT(a.id_autor) from tb_livros as l join tb_autores as a on…
mysqlanswered Anthony Accioly 20,516 -
3
votes1
answer75
viewsA: Get single lines in the database, mysql
You want all pets with a single entry in your table. A literal translation of this into SQL assuming that your table name is CUSTOMER_PET would be: SELECT pets FROM customer_pet GROUP BY pets HAVING…
mysqlanswered Anthony Accioly 20,516 -
0
votes1
answer52
viewsA: Error including name attribute in @Webservice
This is a specific validation of a Eclipse JAX-WS plugin (class). While validations give good tips, they’re not necessarily errors. The developer of the JAX-WS implementation can do whatever they…
-
1
votes1
answer110
viewsA: Doubt with C Pointers
prev and temp are pointers. That is, they are variables, living in their own memory address, whose value is an address to another place in memory. int x = 5; // variável com o valor 5 int *y =…
-
3
votes1
answer46
viewsA: Interpreting code with bundled classes
On the compilation The first thing you have to keep in mind is that src is not part of the package structure, it is only the base directory that contains the source code of the application. javac -d…
javaanswered Anthony Accioly 20,516 -
5
votes2
answers2953
viewsA: My application does not start in Spring-Tools Suite
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) It usually means that one or more jars are corrupted. Maven by default…
-
4
votes3
answers234
viewsA: Global variables recursion
One possible alternative is to use an accumulator parameter: int somaPositivos(int soma, int vet[], int n) { int somaAteAqui = soma; if (n <= 0) { return soma; } else { int aux = vet[n-1]; if…
-
2
votes3
answers953
viewsA: Read txt line and include ";"
Building on the idea of replace with regular expressions suggested in answer from Pagotti, Here is an example that processes the complete file, line by line, according to a specific regular…
-
2
votes2
answers224
viewsA: Setup pointcut AOP Spring
From a look at designators (Pcds) @target, @within and @annotation in spring documentation. See what pointcut expressions can be combined with &&, || and ! to form rules such as: execution(*…
-
7
votes1
answer244
viewsA: Could someone tell me what happens in this method?
The method in question is reading the entire contents of a stream input (e.g., from a file, network port, etc.) to an array of bytes in remembrance. The ByteArrayOutputStream is a stream output that…
-
2
votes2
answers381
viewsA: Hibernate connection problems with Mysql Database
The exception in question, assuming your credentials are correct, is due to the extra space in the JDBC URL jdbc:mysql: //localhost:3306/fj21. To resolve the issue edit the URL in the file…
-
9
votes6
answers1348
viewsA: Is there an alternative to system('cls') in PHP Console?
Try the following: echo chr(27).chr(91).'H'.chr(27).chr(91).'J'; // ^[H^[J Source: PHP clear terminal screen…
-
4
votes1
answer1868
viewsA: How to randomly choose an item from a Python dictionary?
One way to do this in Python 3 is to get a view of the dictionary items and use the function random.choice to choose an element. import random dic = {'Pedro': 99, 'João': 19, 'Rosa': 35, 'Maria':…
-
1
votes1
answer589
viewsA: Request without @Xmlrootelement
TL/DR: Keep JAXB’s notes if you have no greater reason to break the pattern. If you really need something specific enable the Jackson. In current versions of Jersey to standard form to work with…
-
1
votes2
answers720
viewsA: Update date at each update in a table
The function now() returns the current date. One way to automate this mechanism is by using a Trigger as the code below: CREATE OR REPLACE FUNCTION update_pe_modified_column() RETURNS TRIGGER AS $$…
-
15
votes5
answers5742
viewsA: Is it possible to develop websites with C/C++?
Yes web programming in C/C++ it is possible, this even refers to the beginning of dynamic web applications. In the 90’s CGI with Perl for text manipulation and C/C++ for "heavy processing" were the…
-
5
votes1
answer470
viewsA: DLL’s communication with Java
As commented by Victor Stafusa, two common alternatives for consuming native code are the JNI (standard Java engine) and JNA (a popular library to consume C libraries). In a rough simplification we…
-
4
votes1
answer119
viewsA: What are Crosscuting Contracts? What is the relationship with Design by Contract?
Design by Contract (Dbc) is an approach to design of software providing for the formalisation of contracts (i.e, pre-conditions, post-conditions and invariants) between customers and suppliers.…
-
1
votes2
answers1346
viewsA: Caused by: java.awt.Headlessexception: No X11 DISPLAY variable was set, but this program performed an Operation which re
Jasper Reports uses some features of awt for image manipulation, but it does not require a "real" graphical environment to generate a report as nothing is actually sent to the display. To generate…
-
8
votes1
answer1657
viewsA: What does code 201 of a Request mean?
In a Rest API it is common to create new features. For example, you post to: http://meudominio.com/minhaApi/meuRecurso This creates a new feature that can be accessed at:…
-
48
votes4
answers3861
viewsA: What are the risks of using permission 777?
When giving permissions 777 for a file you make all users can read, write and run the same. This means that any vulnerability of your system allows an attacker to do as they please with that file.…
-
3
votes2
answers612
viewsA: JSP - Using request in a method
JSP pages are translated to Servlets and then compiled. There is a difference about how translation treats Scriptlets (<% %>) and Declarations (<%! %>). Scritplets are translated into a…
-
5
votes1
answer176
viewsA: mysql driver is not found when the application is rotated from a jar
The "nail" solution would be to include your jar and the Mysql driver jar in Classpath and then rotate the class main: java -cp c:\jars\jdbc_mysql.jar;c:\raiz\java\SistemaCadastro.jar…
-
3
votes2
answers65
viewsA: Checking styles that are not being used on a website
A good way to start is with the Chrome audit tool. To use it: Open the tools for developers (Ctrl+Shift+I on Windows and Linux) Click on the tab Audit. Select Web Page Performance Click on Run…
cssanswered Anthony Accioly 20,516 -
2
votes1
answer255
viewsA: Read and write data to serial port via openedge/Progress
You can open a INPUT STREAM door COM (unfortunately only between 1 and 9): INPUT STREAM MinhaStream FROM value("COM1") Reference: Progress Knowledge Base - How to read data from a serial com port?…
progress-4glanswered Anthony Accioly 20,516 -
2
votes2
answers749
viewsA: Table does not appear in EDMX models
Tables like tb_r_veiculo_adicionais are called relationship tables. Basically, this type of table has no business meaning, they constitute only a way to model relationships n-to-m in the relational…
-
3
votes1
answer41
viewsA: Change Actionbar title in older versions
For older versions you will need to use the method getSupportActionBar(). See that for this your class will have to inherit from ActionBarActivity or AppCompatActivity or instead of Activity: public…
-
8
votes1
answer1510
viewsA: Mask for monetary values
There are several plugins (list of mask plugins for jQuery). For your requirements the jquery-maskMoney seems to be ideal: $("#meuDinheiro").maskMoney(); <script…
-
28
votes1
answer1626
viewsQ: What is Flyweight Pattern?
Researching a little to better understand the logic that leads strings in Java to be immutable, I found out that "internment" of Strings is an example of the pattern Flyweight. In accordance with…
-
1
votes1
answer1031
viewsA: Problem with nextLine() after nextInt() in a Loop
The problem is that the method nextInt() does not consume the line break typed by the user. You need to discard it before calling nextLine() again: pos = entrada.nextInt(); entrada.nextLine(); //…
javaanswered Anthony Accioly 20,516 -
16
votes4
answers724
viewsQ: Java: When to use Interrupt vs flags?
To indicate to a thread that it must "interrupt" its work Java provides a mechanism known as Interrupts: public void run() { while(!Thread.interrupted()) { // Fazer algo } } // para interromper…
-
3
votes1
answer1521
viewsA: Comparison of vectors in C
You don’t need two loops. If both arrays are the same size just check element by element if v1[i] == v2[i] (the pointer syntax is equivalent). As optimization, instead of counting the amount of…
-
0
votes1
answer52
viewsA: Query with jpa + Hibernate with more than one idt in clause
Hibernate 5 or higher supports multi-load: Session session = entityManager.unwrap(Session.class); MultiIdentifierLoadAccess<PersonEntity> multiLoadAccess =…
-
19
votes3
answers2393
viewsA: Divergence in encrypting and decrypting in Java and C# Aes algorithm
First let’s make your code work There are three main differences between the C# and Java implementations of your question: The key The Java-side algorithm is computing a hash (SHA-256) of the…
-
2
votes3
answers855
viewsA: Trigger to update modification date in Firebird
According to Julio’s statement, execute a statement of update in the Trigger is not a very good idea. If this were allowed in your case you would get into loop trying to update the last modification…
-
5
votes2
answers5645
viewsA: Php Mailer error in hostgator
PHP validates SSL certificates. Apparently you don’t have a valid certificate for mail.systembit.com.br in your system. While the correct solution is to install a valid certificate, a work-Around…
-
4
votes2
answers981
viewsA: What is the reason for the error "The Operator / is Undefined for the argument" in this code?
The problem is that the compiler some tool in your build is getting lost in the time to do Unboxing of the kind Double to the primitive double, what is needed to enable division. To be more…
javaanswered Anthony Accioly 20,516 -
5
votes1
answer155
viewsQ: How to modify/evolve a distributed Infinispan cache "hot" without losing entries?
Context I have a cluster with some nodes of the Jboss EAP 6.4. Applications in this node cluster share a cache embedded mode infinispan with UDP synchronous distribution (Jgroups):…
-
3
votes3
answers344
viewsA: Determine the page where the *.pdf file will open in the browser
My original comment, to reply from José and the response of Cleidimar show the way to point a client-side page. That is, make the PDF reader open the document on a specific page. Another possible…
-
13
votes1
answer333
viewsQ: Why are arrays covariant and generic are invariant?
Arrays in Java are covariant, that is, it’s perfectly cool to do something like: Number[] meuArray = new Integer[10]; Generic types are invariant. The line below does not compile: List<Number>…
-
5
votes1
answer326
viewsA: Copy and write image launches java.lang.Illegalargumentexception: image == null!
Of the documentation of ImageIO.read: Returns a BufferedImage as a result of the decoding of File supplied with a ImageReader automatically chosen from among those currently registered. If no…
javaanswered Anthony Accioly 20,516 -
6
votes1
answer7283
viewsA: How to format monetary value in Laravel
To do this on the server side with PHP use the function money_format. For example: {{ money_format('%n', $lst->vl_valor_tot_contrato ) }} Also remember to set the locale correctly in PHP.…
-
0
votes2
answers446
viewsA: Java Spring Extender @Scheduled to read a file
Updating Spring properties with the running application is usually a non-trivial problem. This way it is often easier to implement this type of scheduling in a programmatic way: @Autowired private…
-
2
votes2
answers2251
viewsA: Oracle - How to force a field size on a Function return
Unfortunately in user-defined functions it is not possible to specify the return size of the VARCHAR2. As you yourself noted, even guaranteed that the function never returns a VARCHAR2 greater than…
-
3
votes2
answers614
viewsA: How to get current directory of a web application?
Alternative: URL location = getClass().getProtectionDomain().getCodeSource().getLocation(); System.out.println(location.getFile()); The advantage of this version is that it also works with paths…
javaanswered Anthony Accioly 20,516 -
18
votes1
answer467
viewsQ: Are there alternatives for reflection/introspection in C++?
I have the following problem. Given some kind of a guy T: template <typename T> I need to be able to convert an object like T on a map std::unordered_map<std::string, boost::any>…
-
4
votes1
answer757
viewsA: Configure the spreadsheet created by java with jxl
You can center the text of a cell using the method setAlignment class WritableCellFormat. For example: WritableCellFormat cellFormat = new WritableCellFormat();…
javaanswered Anthony Accioly 20,516