Posts by Sorack • 27,430 points
864 posts
-
1
votes1
answer80
viewsA: As popular jtable with xml file titles
To read the files return a list you can use the following method: private List<String> lerNomesArquivo(String caminho) { File pasta = new File(caminho); List<String> nomes = new…
-
2
votes3
answers1003
viewsA: Pass value to service Factory in Engineering
You can simply pass them as a parameter to the function you created. Parameters are for that very purpose and you can confirm here Angular Styleguide - Factories.…
-
1
votes1
answer196
viewsA: Stack Underflow Error and Access Violation Delphi 7
The problem of access Violation in reality is the component Rxlib - Delphi 7 that needed to be installed. Rave Reports error must be connected with this!…
-
4
votes1
answer5807
viewsA: Percentage in Java
I rewrote your problem because although the error is due to division of int for int,the variable names confused. Then I followed as default put the number referring to the type right after the…
-
1
votes1
answer86
viewsA: Why is my String names accepting whole numbers instead of letters?
You have to use next() reading the name instead of nextLine(). And also in option 2 you have to use the variable i instead of indice us System.out.println student. The code is incomplete from what I…
-
3
votes2
answers210
viewsA: Sum if in Mysql Workbench
For the expected result you should group by order number and courtesy and not try to separate into different columns. select No_Pedido, sum(valor), Cortesia from tabela group by No_Pedido, Cortesia;…
-
4
votes1
answer89
viewsA: How can I get the BD date already formatted using the Max and Date_format functions together
You must first find the date using the MAX and only after this format, otherwise the database will understand that you should search using alphabetical order. Correcting the position would have:…
-
3
votes2
answers616
viewsA: Postgresql Trigger apos update
First, create a function that returns the type trigger: CREATE FUNCTION validar_email() RETURNS trigger AS ' BEGIN IF EXISTS (SELECT FROM invalido WHERE ds_valor = NEW.email) THEN NEW.email :=…
-
1
votes1
answer88
viewsA: Reading via Socket
The problem seems to be with the charset. Force the charset for UTF-8 on the following lines (34, 35): BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(),…
-
0
votes1
answer192
views -
2
votes1
answer962
views -
2
votes3
answers11309
viewsA: How to delete duplicate spaces in a string?
There is a very interesting way also that works practically for any language. Worth the curiosity. let str = '00000.00000 111111111.111111111111 33333333'; str = str.split(' ').join('<>');…
-
3
votes2
answers223
viewsA: Comparator - Priorityqueue
EDIT 1 - Com Priorityqueue In case you really need to use PriorityQueue to sort, I suggest creating a control variable to know the insertion order. Create a class variable to control the last…
-
0
votes2
answers2567
viewsA: How to format a date displaying the month name in angular?
If you wish to use purely Javascript: function formatarDataExtenso(data) { // Meses possíveis var meses = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro',…
-
1
votes1
answer193
viewsA: Mysql Function returning NULL
Your select has some problems: The instruction INTO must be shortly after the declaration of the select; The field idPasta is with _ in Join; Prefer to use inner join; It would look more or less…
-
1
votes3
answers3652
viewsA: print json on pure javascript screen
Going for the simplest: function imprimirJSON(json) { console.log(JSON.stringify(json)); } And the call you make for: imprimirJSON(meuJSON); JSON.stringify() The method JSON.stringify() converts…
-
0
votes2
answers1587
viewsA: SQL Syntax Error in FK Creation
We’re missing a () in the creation of the foreign key. It would look like this: FOREIGN KEY(`crm`) REFERENCES `medico`(`crm`)
-
0
votes2
answers852
viewsA: How to Throw the dice of a Jlist into another Jlist that is in another Jframe?
Using two frames, one with a list and a button I will call a reference. First I create the list with the items: DefaultListModel model = new DefaultListModel(); jListReferencia.setModel(model);…
-
1
votes1
answer209
viewsA: Case for several fields
Yes, but to use this type of case you cannot have the fixed value right after the case and the tests shall be carried out in the when as follows: select *, (case when pergunta1 = 1 and pergunta2 = 1…
-
1
votes2
answers152
viewsA: How to make a functional string analysis method?
Using regular expression your code will be simpler and easier to maintain. It would look like this: public Boolean nomeConfere(String nome) { if (!nome.matches("^[A-Z ]+$")) {…
-
2
votes1
answer60
viewsA: Mysql doubt in Select
Taking into account that the name of your table would be chat to query would look more or less like the following: SELECT c2.id, c2.id_from, c2.id_to, c2.message FROM (SELECT MAX(c1.id) as id FROM…
-
1
votes2
answers1259
viewsA: Error making query with between in datetime field
Run in your database: SET DATEFORMAT ymd; Correct is you change the language of your database, so it will work in the default 'yyyy-mm-dd'. If you want to use it the way it is, the format is:…
sql-serveranswered Sorack 27,430 -
1
votes1
answer683
viewsA: Gson: Jsonobject to Jsonarray conversion error (Jsonprimitive cannot be cast to com.google.gson.Jsonarray)
The problem is that the format of your JSON is incorrect. When you have an array, it cannot be inside ". Your corrected JSON would look like this: { "produtosFavoritos":[], "listas":[],…
-
0
votes2
answers128
viewsA: How to insert primary keys from an X table into a Y table
You can take the inserted codes while include in the table using LAST_INSERT_ID. For example: INSERT INTO pessoa ... SET @id_cliente = LAST_INSERT_ID(); And then use the variables that were obtained…
-
3
votes1
answer110
viewsA: Dynamic insertion according to date and days of the week
You can create a Event Scheduler in the database. First enable the resource: SET GLOBAL event_scheduler = ON; or SET GLOBAL event_scheduler = 1; Then create the event. In the following case the…
-
3
votes1
answer3906
viewsA: Angularjs Filter with Argument Array
Use a custom filter. View <ul ng-repeat="item in itens | filter: filtrarCores"> <li>{{item.nome}}</li> <li>{{item.cor}}</li> </ul> Controller var filtro =…
-
3
votes1
answer1384
viewsA: create a global role in Vue
To add a global method to Vue you can create a plugin: According to Vue.js - Plugins: MeuPlugin.install = function (Vue, options) { // 1. Adiciona o método global ou propriedade Vue.meuMetodoGlobal…
-
3
votes1
answer340
viewsA: How to view a list from a Json sub-array?
Using the HTML of the form below works normally: var html = ""; var participantes = [ {nome_usuario: "Albson Xavier", id_usuario: 1786, login: "[email protected]"}, {nome_usuario:…
-
18
votes1
answer3299
viewsA: How to compare two Arraylist and get the values shared by both?
With Java 8 you can solve using expression lambda to filter only the records in which the city is contained within the array city filter. List<VagaEmprego> encontradas = vagas .stream()…
-
3
votes1
answer269
views -
4
votes2
answers556
viewsA: Insert foreign keys
The foreign key is for you to link a record from one table to another, that is, it will not automatically fetch information for you in another table. And table structure for what you want would look…
-
2
votes1
answer82
viewsA: Angularjs - modal inserts template with radio button options
This Plunker contains the following corrections for the operation of its modal: The ui.bootstrap script files were imported; <script…
-
2
votes3
answers658
viewsA: Pass SQL output to JSON
Try to change your content while to the following: while($row = mysqli_fetch_assoc($result)) { $vclientid = $row['client_id']; $vname = $row['name']; $vemail = $row['email']; $rows['client'][] =…
-
2
votes1
answer250
viewsA: Error while performing sql server + php + Pdo query
Run the following function in your database: if object_id('dbo.batidas', 'TF') is null begin exec('create function dbo.batidas() returns @retorno table(T int) as begin return end'); end; go alter…
-
1
votes3
answers1544
viewsA: HTTP post in Angular
You’re trying to access a service from a local file. This is not possible by the same origin policy unless you enable server-side access by sending Access-Control-Allow-Origin: * us headers. In…
-
1
votes2
answers156
viewsA: Grab Files on Drive C:
To take the path to the folder where the . jar is running you must use the following code, swapping MinhaClasse by the name of the current class: MinhaClasse .class .getProtectionDomain()…
-
0
votes1
answer199
viewsA: Remove selected item in new selection in spinner
First get the desired item from Spinner: int pos = 0; object item = m_adapterForSpinner.getitem(posicao); After obtaining the object, remove the item from the adapter of Spinner:…
-
1
votes2
answers131
viewsA: Scanner - Split regardless of the number of columns
Check with the nextLine as in the example below, so you have control of the line and with the split can check how much information it contains and decide what to do with the information: public void…
-
1
votes1
answer180
viewsA: Set object in Angular JS
Use ng-option as follows to get only the id of the selected house: ng-options="item.id as item.referencia for item in casas.list" Or use as follows to obtain the complete object with reference:…
-
1
votes1
answer1330
viewsA: take input values
If you are using angular, as the last snippet of code posted in the question suggests, the value will be in the variable used in ng-model. Then it would look like this: $scope.fones = function () {…
-
12
votes3
answers1653
viewsA: Picking up part of the phone
First replace the special characters and then take the first 2 characters. // Remove qualquer caracter que não seja numérico numero = Regex.Replace(numero, "[^0-9]+$", ""); // Pega os 2 primeiros…
-
0
votes1
answer86
viewsA: Modify Dates of each object - MONTH, YEAR
Solution 1 (Recommended): In the Java 8 you can use the new API JSR-310 inspired by Joda-Time. This library can also be downloaded to Java 7 here: LocalDateTime.from(data.toInstant()).plusDays(1);…
-
1
votes2
answers158
viewsA: Mysql update filtering by due date with tolerance of x Days
In your example you are putting the tolerance on the current date and not the due date. The update would thus be on the correct date: UPDATE finan SET status = 'Vencido' WHERE status = 'Em Aberto'…
-
1
votes1
answer188
viewsA: Delete selection from a List
For the package java.awt.List, in accordance with the Javadoc, to clear the selection you must use the method deselect(int index). The index can be given by the method getSelectedIndex() as in the…
-
4
votes1
answer698
views -
2
votes3
answers1154
viewsA: How do I allow only numbers and a special character in javascript?
Your code would look like this with a check by regex: if (!/^[0-9]{5}\-[0-9]{3}$/.test(cep)){ alert('digite seu cep corretamente'); document.form.cep.style.background='red'; return false; } EDIT 1…
-
3
votes1
answer334
viewsA: Time Zone Javascript
The number returned by the function getTimezoneOffset is the difference in minutes of local time to UTC, ie, 180 is the equivalent of GMT-3, -120 is the equivalent of GMT+2 and so on. Reference:…
javascriptanswered Sorack 27,430 -
1
votes2
answers55
viewsA: Returning only one select at a time multiuser
I believe that, for the above explanation, the ideal is that you use the function newid() Sqlserver. It will return you a unique hash, preventing two users from getting the same identifier. Example:…
-
3
votes3
answers75
viewsA: How can I exclude the penultimate number from a period?
MONTH will return an integer, so in the conversion the 0 the left will disappear. declare @hoje datetime, @periodo varchar(6); set @hoje = '2016-01-01'; -- Pega o ano + o mês set @periodo =…
-
2
votes1
answer835
viewsA: Function being executed twice jQuery
To avoid duplicate events use the following code before assigning the click: $("#salvar_festa").off("click") And try to assign the click as follows: $(document).on("click", "#salvar_festa", clicar);…