June 22, 2020

Kill process using shortcut in command prompt in windows OS

Problem: When we get a message that port 8080 already in use then it becomes very difficult to use the same port for different processes.

Solution: Just run the below commands in command prompt and whoop! magic happens. 
Follow the screenshot for the reference.

Sample commands:
netstat -ano | findstr :8080 (replace 8080 with your port)
taskkill /F /PID 11237 (replace 11237 with your pid)

A sample screenshot is for port 8088

Run .sql file in Oracle SQL developer

Problem: Some times we have to execute insert queries of a table that we exported in .sql file. For multiple .sql files having huge data, it's not easy to execute those queries using copy and paste in SQL Developer tools.

Solution: To execute .sql file you just need to write the path of your .sql file after @ and then file name with extension with delimiter ';' in the end. Select the complete command and press yellow highlighted green triangular button to execute sql script command. Just follow the below image for the reference.
Sample command:
@F:\myData.sql

November 30, 2019

August 11, 2019

FormData.delete() and FormData.set() do not support Internet Explorer

Problem: All methods of FormData do not work/compatible with Internet Explorer. The only method that is successful is 'append'. but suppose you want to override values of specific keys but in that scenarios 'set' and 'delete' methods will not work on Internet Explorer.

Solution: You may use below code that will work on IE.

var form = $('form')[0];
var formData = new FormData();

var inputs = form.getElementsByTagName('input'); //for input box

var inputsList = Array.prototype.slice.call(inputs);
inputsList.forEach(
  function (i) {
     if (i.name !== 'excludedName') {
          formData.append(i.name, i.value);
     }
   }
);
formData.append('excludedName', 'value you want to set');

Note: for 'select' and 'textarea' use: 
var selects = form.getElementsByTagName('select');
var textareas = form.getElementsByTagName('textarea');

April 16, 2018

org.hibernate.AnnotationException: No identifier specified for entity

When I was working with hibernate project. I got this exception. Actually, the issue was because of missing @Id from one of my entity class. @Id is used on the primary key field in the entity class. The field is a primary key in your database table.

If you do not have any primary key in your database table then you can use rowId as the primary key for your entity class.

@Id
@Column(name = "ROWID", insertable = false, updatable = false)
private String rowId;

February 4, 2018

error: possible loss of precision using Math.pow in java

Problem : I compiled below code and got possible loss of precision error.
int a = Math.pow(3, 5);
System.out.println(a);

Solution : According to the java documentation, Math.pow() expects two doubles, and returns a double. When you pass two int values to this method, it converts an int to double. But when we assign the value to an int, it gives, possible loss of precision error while compiling the code. So you can cast method to an int or assign the returning value to double to resolve the error.

int a = (int)Math.pow (3,5);
or
double a = Math.pow (3,5);

Disclaimer

We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.