Blog Archive

Friday, 22 July 2016

Filter in AngularJs

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
var app=angular.module('myApp',[]);
app.controller('ct',function($scope){
$scope.arr=["Shiv","Jagan"];
});
</script>
</head>
<body>
<div ng-app="myApp" id="u" ng-controller="ct">
Name<input type="text" ng-model="userName"/>
<ul>
<li ng-repeat="x in arr|filter:userName">
User Name:{{x}}
</ul>

</div>

Angular Js HelloWorld

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
var app=angular.module('myApp',[]);
app.controller('ct',function($scope){
$scope.Name="Shiv";
});
</script>
</head>
<body>
<div ng-app="myApp" id="u" ng-controller="ct">
Name<input type="text" ng-model="Name"/>
User Name:{{ Name}}

</div>

Tuesday, 12 July 2016

Exception Handling puzzle

Hi please pay close attention to this small code snippette.
As our rule says exception handling mechanism
The finally block always gets executed even if we are using the return statements.

The code will return the OP as 30

public class TryCatchDemo {
static int giveInt()
{
     try
     {
           return 10;
     }
     catch(Exception e)
     {
           return 20;
     }
     finally
     {
           return 30;
     }
    
     }
     public static void main(String[] args) {
     System.out.println(""+giveInt());

     }

}


StringBuilder Demo


public class StringBuilderDemo {

     public static void main(String[] args) {
            StringBuilder sb = new StringBuilder("Shiv");
          
               System.out.println("Original String " + sb);
            
               System.out.println("substring: " + sb.substring(0,2));
          
 //  StringBuilder java.lang.StringBuilder.replace(int start, int end, String str)
               sb = sb.replace(4,4,"!!!!");
               System.out.println("replace String from location 4 to 4 charecters from location 4  " + sb);
            
               System.out.println("indexOf() charecter S is   " + sb.indexOf("S"));
            
    //Syntax StringBuilder java.lang.StringBuilder.insert(int offset, String str)
               sb = sb.insert(5, "is");
               System.out.println("inserted String  " + sb);
              
              //Syntax StringBuilder java.lang.StringBuilder.append(String str)
               sb = sb.append(" lord");
               System.out.println("append: " + sb);
          
               System.out.println("lastIndexOf charecter i is  " + sb.lastIndexOf("i"));
               sb = sb.reverse();
               System.out.println("reverse: " + sb);
     }

}


String Demo


public class StringDemo {

       public static void main(String[] args) {
       String s=new String("Shiv");
      
       char firstChar=s.charAt(0);
       System.out.println("First Charecter"+firstChar);
      
       boolean status=s.contains("i");
       if(status){
              System.out.println("i Found");
       }else{
              System.out.println("i Not Found");
       }

       status=s.endsWith("iv");
       if(status){
              System.out.println("ends with iv");
       }else{
              System.out.println(" Not ends with iv");
       }

       String newString=s.replace('v', 'V');
                     System.out.println("Replaced= "+newString);
      
       String name="Ajju";
       System.out.println("Last Occurance of J= "+name.lastIndexOf("j"));
       System.out.println("First Occurance of J= "+name.indexOf("j"));
       //**Substring starting from point 2*/
       System.out.println("SubString"+name.substring(2));
      
       name="Java is Great";
      
       String []words=name.split(" ");
      
       for(String oneWord:words)
       {
              System.out.println(""+oneWord);
       }
      
       }
      
      
}


Wednesday, 22 June 2016

Difference between TRUNCATE, DELETE and DROP commands

 

1>TRUNCATE is a DDL command whereas DELETE is a DML command. 2>When compared with delete TRUNCATE is much faster than DELETE.

Because 

Step 1:When you DELETE.all the data first gets copied into the Rollback Tablespace first.

 

Step2: Then delete operation get performed.

Benefit of delete is  when you  ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).

 

But when you type TRUNCATE,it removes data directly no extra copy is maintained .Thats why TRUNCATE is faster.

 

Once you Truncate you cann't get back the data.


3>You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.

 

4>In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.


5>You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause

1>TRUNCATE is a DDL command whereas DELETE is a DML command.

2>TRUNCATE is much faster than DELETE.

Reason:When you type DELETE.all the data get copied into the Rollback Tablespace first.then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the Rollback Tablespace).All this process take time.But when you type TRUNCATE,it removes data directly without copying it into the Rollback Tablespace.Thatswhy TRUNCATE is faster.Once you Truncate you cann't get back the data.

3>You cann't rollback in TRUNCATE but in DELETE you can rollback.TRUNCATE removes the record permanently.
4>In case of TRUNCATE ,Trigger doesn't get fired.But in DML commands like DELETE .Trigger get fired.

5>You cann't use conditions(WHERE clause) in TRUNCATE.But in DELETE you can write conditions using WHERE clause