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;
       }
   });
     }