Posts by bruno • 7,237 points
193 posts
-
5
votes4
answers15572
viewsA: What is the super() function for;
In Java super() invokes the constructor, without arguments, of the derived class (parent). In your example, and since UsuarioController extend the class HttpServlet will invoke the constructor…
-
3
votes1
answer309
viewsA: Accessing values from an object array
The problem then lies in the function AlocaCarro(...). You should make a copy of the object and store it in your matrix. Currently you are creating a single object, which you change during the…
-
2
votes3
answers257
viewsA: Error in formula with OR
Several answers have already been submitted, but here is a more concise alternative to what you want to get. =SOMA(SE((E:E>120)*(E:E<139)+(F:F>80)*(F:F<89);1;0)) A detail quite a lot…
-
3
votes2
answers2579
viewsA: Get last record of each id in sql query on condition
I understand that when you say the last record you want the one with the most current date. select c.Serial, v.Descricao, v.Placa, v.Cor, v.AnoFabricacao, v.Chassi, max(c.DataHora) as DataHora,…
-
1
votes3
answers61
viewsA: BD Results Count for pagination
From the PHP documentation regarding the function rowCount() If the last SQL statement executed by the Associated Pdostatement was a SELECT statement, some Databases may Return the number of Rows…
-
6
votes2
answers2119
viewsA: Resume a list without repeats
I’m assuming this is the output you want. aaabbbcddd abcd aaabbbaaacddd abacd For that you can try something like. Version 1: removeDups :: (Eq a) => [a] -> [a] removeDups [] = [] removeDups…
-
8
votes1
answer152
viewsA: Check whether it is palindrome (No instance for (Eq a) arising from a use of `==')
In your function you are comparing two instances of a type (generic) using ==. This imposes a restriction, implying that the type cannot be completely arbitrary. The type has to be an instance of…
-
1
votes2
answers5027
viewsA: Product of Matrices
The error in your code is in the way you index matrices. Try it like this: public static int[][] calculaProduto(int[][] a, int[][] b) { if (a[0].length != b.length) throw new…
-
2
votes1
answer66
viewsA: Qcustomplot how to resize graph?
Normally the graph scale should be determined automatically so that all values are visible. Apparently, in your case, this isn’t happening. You can force a scale using the method setRange(int x, int…
-
2
votes1
answer1340
viewsA: Showing total size of a directory
This solution should work on any platform with php 5 or higher. function GetDirectorySize($path){ $bytestotal = 0; $path = realpath($path); if($path!==false){ foreach(new…
-
3
votes1
answer180
viewsA: Select database record for variable
For the purpose you describe is correct. You can however make a small change by removing the use of echo, if you are using a sufficiently current version of the bash shell that supports "here…
-
2
votes1
answer177
viewsA: SQL: Can I have clauses in Groupby that don’t appear in Select?
I’ll answer for the two Sgbds in the question tags: Group By gathers a set of records and produces a summary (a single record) for each of the identified groups. Groups are identified on the basis…
-
2
votes2
answers183
viewsA: How do I insert complex numbers into C++?
In c++ you have the type Complex. It can be used as follows: // 1 + 2i std::complex<double> c(1, 2); The constructor takes two parameters: The first, the real part of the number The second,…
-
3
votes1
answer1395
viewsA: How to make a button blink?
I’d do it this way: A Java Swing Timer to control the whole process Every 0.3s an event that you process through an Actionlistener is triggered In Actionlistener you choose the color randomly and…
-
1
votes2
answers682
viewsA: Filter String Array records by space-separated words in Java
The problem is probably the regular expression you’re using. Follow a small example (you may have to make some adjustments, but I think it should work) import java.util.regex.Pattern; import…
-
3
votes1
answer3605
viewsA: A cursor inside another sqlserver cursor
First of all it should be said that there are few problems that need cursors to be solved in SQL. That said, apparently you are not closing and releasing (dealocate) the cursors. CLOSE cursor_tab2…
-
3
votes2
answers135
viewsA: Is it possible to add an empty directory to a Git repository?
According to the documentation is not possible. Can I add Empty Directories? Currently the design of the Git index (staging area) only Permits files to be Listed, and nobody competent enough to make…
-
12
votes2
answers15219
viewsA: Grab the file extension
Your code is very close to what you are trying to get. Try this way: $ext = pathinfo($filename, PATHINFO_EXTENSION); The function pathinfo can receive various options according to your needs:…
-
1
votes2
answers5100
viewsA: How to search in txt file?
In C++ you can do as follows: string getNome(string numero) { ifstream ifs( "ficheiro.txt" ); string linha; string resultado = "Nada foi encontrado"; while( getline( ifs, linha) ) { if…
-
0
votes2
answers86
viewsA: How to take the file path and insert it into a table?
I don’t know any alternative to Sql Server xp_dirtree that allows you to directly import filenames. To get the same result you can try as follows. First create a file with your directory listing.…
-
2
votes2
answers695
viewsA: SQL does not return all results that should return
SELECT Electrodomestico FROM Produtos p INNER JOIN Sites s ON locate(s.URL, s.URL) > 0 WHERE s.id = 1 This should return all records. Edit: The way you want to do it you can try: SELECT…
-
12
votes1
answer7582
viewsA: What is the advantage of using CHAR instead of VARCHAR?
For starters, it always depends on the DBMS.In theory: VARCHAR is used to store strings of variable size and uses dynamic memory allocation. CHAR has fixed size and static memory allocation.…
-
2
votes1
answer171
viewsA: Reporting
The problem lies here instruction: cmd.CommandText = "SELECT * FROM tbEntradaEstoque WHERE CONVERT(DATE, data_ent) = @dataEnt"; (...) cmd.Parameters.Add("dataEnt", SqlDbType.DateTime).Value =…
-
4
votes1
answer149
viewsA: Wrong file size
The function filesize returns the size of a file in bytes, so you should not do $tamanhoarquivo /= 1024; But yes $tamanhoarquivo /= 1000; An important note from the function manual (may not apply in…
-
2
votes1
answer1279
viewsA: How to copy a file inside the jar to a folder outside of it?
In your method of image you should use: getResourceAsStream() InputStream input = getClass().getResourceAsStream("/pacote/imagem/" + fileName); When the resource (image, text file, ..) is…
-
1
votes3
answers300
viewsA: Recover groups of a regular expression in Perl
Try it this way: $version="2.2.1-ALPHA30"; my @resultados = $version=~/([\d]+)+/g; print join(", ", @resultados); I only used print to show all the results that were captured. You can use the array…
-
0
votes1
answer2443
viewsA: Battleship Java
Here is a sketch of what you can do to validate whether the ship can be placed on the board. private boolean estaLivre(int fila, int coluna, int tamanho, int direcao) { boolean eValido = true;…
-
0
votes1
answer102
viewsA: store php log id
Uses the last_insert_id function() In your case: $sql_1="insert into agregado (nome, parentesco, idade, bi) value('$agregado[$i]', '$agregado[$p]', '$agregado[$e]', '$agregado[$b]')"; $resultado_1 =…
-
1
votes1
answer139
viewsA: Generate monthly graph
Surely this could be solved in your application. But here is an alternative to solve this in the database. This is a solution to a well-known problem. select b.Data, a.id, a.valor from tbl_tabela a…
-
3
votes3
answers2583
viewsA: SQL of tables with multiple relationships
The structure you have right now allows you to answer your two questions: "store the total number of videos of a genre in such a way that it is possible to take, for example, all the movies of user…
-
3
votes3
answers11380
viewsA: How to copy objects in java
Yes, just define the Constructor method class MinhaClasse { private String str; public MinhaClasse (MinhaClasse outro) { this.str= outro.str; // tens acesso directo } } All Objects have a clone…
-
3
votes1
answer314
viewsA: Reading entire file
This is the canonical way to read a file sequentially in C++ #include <iostream> #include <fstream> #include <string> using namespace std; int main() { ifstream ifs( "myfile.txt"…
-
1
votes1
answer804
viewsA: check the time periods available in the SQL table
You can just try: select * from cad_compromisso where data_entrada = '" & calendario.Value & "' and nome_func = '" & cmbfuncionario.Text & "' and ( '" & cmbhorario.Text & "'…
-
14
votes1
answer569
viewsA: What is Sargable argument?
I know this question is almost a year old but I think that maybe the answer might interest someone. Briefly a predicate or condition is considered sargable (Search Argument Able) if DBMS can take…
-
1
votes1
answer1230
viewsA: Count and Display Records from different PHP/MYSQL tables
You can try it like this: SELECT Gender, COUNT(DISTINCT CASE WHEN GENDER = 'Male' THEN booking.customer_id END) [#Male], COUNT(DISTINCT CASE WHEN GENDER = 'Female' THEN booking.customer_id END)…
-
1
votes2
answers261
viewsA: Inner Join display last status
I understand that when you say, "last status" you intend to return only the one with the latest date. If so you can just do: SELECT numero.id, numero.numero, status.status, MAX(status.data) DATA…
-
0
votes1
answer190
viewsA: Error while moving File . rar from one folder to another
May I suggest several alternatives to the method you are using. 1). Since Java 7 you can use NIO2 to copy files. 2). If you cannot use this version (or more current) you can still try using the…
-
3
votes2
answers239
viewsA: Retrieve database records by date field?
From what I understand you can just do the following: select nome, dt_nascimento from tbl_tabela1 where TIMESTAMPDIFF(YEAR, dt_nascimento , CURDATE()) between 18 and 30 I am assuming that the date…
-
1
votes3
answers183
viewsA: Insert values from table B in table A if they do not exist
You haven’t specified which BDS you’re using. However, here is an alternative to SQL Server that is often faster than the answers that have already been posted. MERGE tabelaA AS Target USING (SELECT…
-
1
votes1
answer134
viewsA: MYSQL - Return occurrences closer to REGEXP
This should help you achieve what you want. SELECT * , MATCH (nome_produto) AGAINST ('vestido longo manga curta' IN BOOLEAN MODE) AS relevancia FROM tabela WHERE MATCH (nome_produto) AGAINST…
-
11
votes2
answers15638
viewsA: What is the difference between Function and Procedure?
Functions and procedures serve different purposes. A function, thinking of its mathematical definition, is usually used to calculate a value based on a given input. A function does not allow changes…
-
2
votes2
answers686
viewsA: Full Join N-N without repeating records
A possible solution to your problem is to create a column that links the two tables. This example creates a pseudo relation within each OP. ;with pOrcado as ( select op, [Item Orçado], row_number()…
-
2
votes2
answers6106
viewsA: Mysql group_concat() in Sqlserver
SELECT tipo, STUFF((SELECT ', ' + CONVERT(VARCHAR, tipo) + ' - ' + descri FROM table_t iT WHERE iT.tipo = T.tipo ORDER BY tipo FOR XML PATH, TYPE).value('.[1]', 'NVARCHAR(max)'), 1, 2, '') AS…