Thursday, February 21, 2013

Hibernate tutorial


Hibernate is a powerful high-performance Object/Relational persistence and query service for Java applications. In Hibernate it maps object oriented classes to the database tables and also provides data query. It’s so simple and easy.

Before come to Hibernate, I’ll get some time to explain where it is come from.

There are some mismatches, when mapping object oriented classes and relational databases. Here we want to use a technique to map them correctly. So Object Relational Mapping here. Object Relational Mapping is used for avoid following mismatches between   object oriented classes and relational data bases.

There may be more classes than the number of corresponding tables in the data base. Relational data bases do not defined any similarity to inheritance which is main concept in OOP. RDBMS only has concept of sameness while OOP has object identity and object equality. RDBMS is used foreign key for association columns while OOP is used object reference. The method of access to object class and RDBMS is different.

For more clear, I’ll give you a example for class and data base table.
public class Student {
   private int id;
   private String name;
   private int telno;
   

   public Student() {}
   public Student(String name,int telno) {
      this.name = name;
      this.telno = telno;
   }
   public int getId() {
      return id;
   }
   public String getName() {
      return name;
   }
  
   public int getTelno() {
      return telno;
   }
}

Above program is Java student class and By creating a object we are going to store data in following table.

create table STUDENT (
   id INT NOT NULL auto_increment,
   name VARCHAR(30) default NULL,
   telno INT  default NULL,
   PRIMARY KEY (id)
);

There are some advantages over traditional JDBC (Java Data Base connectivity). There are no need to deal with data base implementation. It hides details of SQL queries from OO logic. Entities are based on business concepts rather than database structure. It is developed application faster.

There are many Java ORM Frameworks. Here we use Hibernate framework which provide services to store and retrieve objects from relational data base.

Hibernate exist between java objects and database server to handle object –relational mechanisms and patterns by mapping java classes to database tables and from java data types to SQL data types.








Hibernate supports RDBMS like MySQL, Oracle, HSQL Database Engine, DB2/NT, PostgreSQL, FrontBase, Microsoft SQL Server Database, Sybase SQL Server , Informix Dynamic Server and technologies like J2EE, Eclipse plug-ins, XDoclet Springand, Maven.



Friday, February 1, 2013

Introduction to Python for Beginner


Python is a dynamic interpreted object oriented scripting language. Python can execute in 2 modes. There are, Interactive mode using the terminal or command prompt and  scripting mode using “.py”  file. The most powerful advantage in python is source code does not declare the types of variables or parameters or methods. According to your syntax of initializing of variable, compiler understand the variable is which type. So codes are more flexible and short. Other important thing is, there no “{}”  to define indentation. Indentation takes place by tab spacing. Be careful when coding you have to maintain the indentation correctly. If you unable to maintain the indentation correctly, your Programming may execute different way. Now I think you have the background knowledge. So let’s begin with installation.

Installation
You can download in here. If you are using CentOS , it comes with python 2.6 version. In Linux terminal
You can find the python installed location by command “ whereis python”.




You have to set the Environmental PATH variable.
If you are programming with terminal you have to convert  to the python interpreter by typing “python” command.




To terminate the Python we should use Ctrl + D.

Install Eclipse plugin for Python


If you are using IDE ,You have to use plugin for python. Let me describe it using Eclipse IDE.
1.Open Eclipse IDE à Help in menu bar à Eclipse Marketplace.


2.Type “pydev” in find field and click go. Then click the “Install” button in “ PyDev – Python IDE for Eclipse”.








3.Click Window in menu bar-à Preferences àPyDevàInterperter- PythonàNew.





5.Give any name as “Interpreter Name” and Browse where the  python executable file(python.exe) is to “Interpreter Executable” and OK  .If it found the executable file It will show you.Then click OK.





6.Then to open the perspective, WindowàOpen Perspective à Other àPyDevàOK.




Now Environment is ok.
First you have to create a project.
File à New àPyDev Project àGive a project name. àFinish.





Then you have to make a new python file.
Select the project àNew à Fileàtype a file name with “.py ”extention. à Finish.



This is the time for coding.get your hands dirty with coding.

The Hypervisor

 The hypervisor is a piece of software that runs on top of hardware infrastructure that creates a virtualization platform. The hypervisor a...