Thursday, August 1, 2013

Avoid "Grid Layout Exception" in Jasper reports

When it is creating multiple reports by threads in Jasper, you will get "Grid Layout Exception" occurred by the jasper library. To avoid that, you can add the following property to JVM.

JRProperties.setProperty("net.sf.jasperreports.text.measurer.factory", "net.sf.jasperreports.engine.util.JdkGlyphFixTextMeasurerFactory");

How to get Linux bash command list

Type history in the Linux terminal and enter.

This will list all the commands you executed in the bash.

Wednesday, July 31, 2013

Count number of files in a directory using Linux command

Following command can be used to get number of files in the directory. This "maxdepth" option lets you to define maximum depth (sub directory levels) to search files.

find ./targetdir/ -maxdepth 20 -type f -follow | wc -l

Thursday, July 4, 2013

Create RSA public & private keys in Linux

Using following command you can create public & private keys in Linux.

ssh-keygen -t rsa

This command can be executed in any SSH enabled Linux machine. RSA keys will be stored in .ssh directory created in your home directory.

Thursday, April 25, 2013

Validate email address in JS

Following java script function can be used to check email validation.

function checkEmail() {        

var email = document.getElementById('txtEmail');      

  var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;        
   if (!filter.test(email.value)) {      
   alert('Please provide a valid email address');      
   email.focus;      
   return false;   
}

Wednesday, April 17, 2013

Informix set connection timeout

jdbc:informix-sqli://192.168.2.15:1528/database:INFORMIXSERVER=online;user=sujith;password=sujith;INFORMIXCONRETRY=3;INFORMIXCONTIME=60

Above JDBC connection URL can be used for connection timeout issues in Informix database.

INFORMIXCONRETRY : connection retry times
INFORMIXCONTIME : connection time

Connection timeout can be occurred due to database slowness and after maximum connection reach.
You have to change JDBC connection URL.

Thursday, April 4, 2013

Verify HOST servers entrusted certificates in JAVA

In sometimes, it has to be trusted the certificates in JAVA client when applications are developed. This may occur when hosting URL doesn't match with certificate URL.

Following JAVA code can be used to verify host as a trusted host.

   static {
   javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
new javax.net.ssl.HostnameVerifier(){

   public boolean verify(String hostname,
               javax.net.ssl.SSLSession sslSession) {
       if (hostname.equals("192.168.11.123")) {
          return true;
       }
          return false;
       }
   });
     }