Earn 50$ & Learn...Become Author of this blog

Find Duplicate Records MySQL Query

Friday, August 22, 2014

Hi All

I know that this is not related Liferay but i came across this useful thing during my development where you can find duplicate record from table and can delete if you need.

SELECT tablename.name FROM tablename
INNER JOIN (SELECT name FROM tablename
GROUP BY name HAVING count(name) > 1) dup_record ON tablename.name = dup_record.name


Read Files From Folder

Wednesday, August 20, 2014

Hi All,

You can use below code to read files from specific folders :

import java.io.File;
public class Test {
    /**
     * @param args
     */  
public static void listFilesForFolder(File folder) {
       
        for (File fileEntry : folder.listFiles()) {
            if (fileEntry.isDirectory()) {
                listFilesForFolder(fileEntry);
            } else {
               
                System.out.println(fileEntry.getName());
            }
        }
        System.out.println("Total :" +folder.listFiles().length);
    }

Migration liferay-6.0.6 to liferay6.2

Wednesday, August 13, 2014

To migrate liferay 6.0.6 to liferay 6.2 we need to follow below steps.

Step 1. First we need to migrate liferay-6.0.6 to liferay-6.1.
  1.     Create 6.0.6 Database dump like (macsiv.sql).
  2.     Create database for liferay-6.1 (macsiv6.1).
  3.     Load liferay-6.0.6 dump into liferay-6.1 database for this use below command
  4.     mysql -uroot -p1 macsiv6.1 < macsiv.sql;
  5.     Download and Unzip clean Liferay 6.1.

Ajax Example with Java

Tuesday, August 12, 2014

Create a Servlet Class as shown below:

Note:- Before we get started with AJAX Example Let me distribute it in separate units
=> URL is important it defines where from we need to fetch the data (In our case we have servlet to be called DisplayUser).
=> What you want from Servlet based on that you can decide what parameters you need to send from your page
=> what is the format of response you need that gets defined from How will data be used internally after getting it processed from servlet
====================================================================
package com.test;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;

Malicious code vulnerability - Java Programming

Thursday, August 7, 2014

Malicious code vulnerability - Field is a mutable array
Malicious code vulnerability - Field is a mutable Hashtable
Malicious code vulnerability - Field isn't final and can't be protected from malicious code
Malicious code vulnerability - Field isn't final but should be
Malicious code vulnerability - Field should be both final and package protected

Performance - Java Programming

Performance - Could be refactored into a named static inner class
Performance - Could be refactored into a static inner class
Performance - Explicit garbage collection; extremely dubious except in benchmarking code
Performance - Huge string constants is duplicated across multiple class files
Performance - Inefficient use of keySet iterator instead of entrySet iterator
Performance - Maps and sets of URLs can be performance hogs
Performance - Method allocates a boxed primitive just to call toString
Performance - Method allocates an object, only to get the class object

Avoid - Java Programming

Avoid Array Loops
Avoid Assert As Identifier
Avoid Calling Finalize
Avoid Catching NPE
Avoid Catching Throwable
Avoid Decimal Literals In Big Decimal Constructor
Avoid Duplicate Literals
Avoid Enum As Identifier
Avoid Instanceof Checks In Catch Clause
Avoid Print Stack Trace
Avoid Rethrowing Exception
Avoid Throwing Null Pointer Exception
Avoid Throwing Raw Exception Types

Bad practice - Java Programming

Bad practice - Abstract class defines covariant compareTo() method
Bad practice - Abstract class defines covariant equals() method
Bad practice - Certain swing methods needs to be invoked in Swing thread
Bad practice - Check for sign of bitwise operation
Bad practice - Class defines clone() but doesn't implement Cloneable
Bad practice - Class defines compareTo(...) and uses Object.equals()
Bad practice - Class defines equals() and uses Object.hashCode()

Most Reading

 

Members

My Followers

Sponsored Links