Tutorials at Free Tutorials Corner

We provide all latest Tutorials in easy way to learn for beginners.Happy Learing .

Placement Papers at Free Tutorials Corner

One place to find all latest placement papers,interview question,interview tips and many more.

Jobs at Free Tutorials Corner

All the latest job - IT, BPO, Government jobs, daily updates .

Tips at Free Tutorials Corner

Technical Tips, Interview Tips, Money Making Tips, etc...

Video Tutorials at Free Tutorials Corner

Video tutorials for all the latest technologies.We are mainly focused to provide Tutorials in Tamil.

Showing posts with label tutorials. Show all posts
Showing posts with label tutorials. Show all posts

Wednesday, 1 May 2013

TCL - Transaction control Language and Create Datebase statement

DCL - Data Control Language(Grant, Revoke )

Grant- is used to provide(grant permission) privileges for database objects.
Revoke-is used to deny(get back the permission) privileges.

TCL - Transaction control Language(Commit, Rollback)

Tcl-is used to control set of actions called transactions like insert, update, delete.
Transaction statement must start with BEGIN transaction_name followed by DML statements.
IF condition followed by BEGIN is IF condition start END is End of If condition

BEGIN TRAN
DELETE EMPloyee WHERE empno = 10
IF @@ROWCOUNT =1
BEGIN
COMMIT TRAN
PRINT 'EMPLOYEE DELETED'
END
ELSE
BEGIN
ROLLBACK TRAN
PRINT 'ROLLED BACK'
END


we use savepoints in TCL to save a particular transactions.
If we use savepoint it saves the transaction that takes place below it.

BEGIN TRAN
DELETE EMPloyee WHERE EmpNO=5
SAVE TRAN E1
DELETE EMPloyee WHERE EmpNO=4
SAVE TRAN E2
DELETE EMPloyee WHERE EmpNO=3
SELECT * FROM EMPloyee
ROLLBACK TRAN E2
SELECT * FROM EMPloyee
ROLLBACK TRAN E1
SELECT * FROM EMPloyee
COMMIT TRAN
SELECT * FROM EMP10



E1, E2 are save points we can able to rollback to any save point before transaction is committed. Once transaction committed changes made permanent .We cannot rollback to save point.

The CREATE DATABASE Statement
The CREATE DATABASE statement is used to create a database.
syntax:

create database database_name
Now we want to create a database called "siva".

create database siva
Now we want to use the created database called "siva".

syntax:
use database_name
use siva

DML - Data Manipulation Language

DML-Data Manipulation Language
Select,Insert,Delete,Update

Select statement
The SELECT statement is used to select data from a database.
The result is stored in a result table, called the result-set.
Syntax:
SELECT column_name(s)
FROM table_name
and
SELECT * FROM table_name
select * from employee
select * from employee where salary > 20000
select * from employee where salary between 15000 and 35000

Insert statement

The INSERT INTO statement is used to insert a new row or record in a table.
Syntax:
It is possible to write the INSERT INTO statement in two forms.
The first form doesnt specify the column names where the data will be inserted,
only their values:
INSERT INTO table_name
VALUES (value1, value2, value3,...)

The second form specifies both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)

insert into employee values(1,'siva','pgr',40000.00,10)
insert into employee values(2,'sakthi','pld',50000.00,20)
insert into employee values(3,'Imrankhan','tml',60000.00,30)
insert into employee values(4,'sachin','pgr',70000.00,40)
insert into employee values(5,'Ranbhir','pgr',40000.00,50)

insert into employee(empno,name,desg) values(6,'Dhoni','kep')
'INSERT'
CREATE TABLE Persons1
(
P_Id int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
INSERT INTO Persons
VALUES (7,'SIVA', 'SAKTHI', 'VIRUDHACHALAM', 'NEYVELI')
select *from persons
INSERT INTO Persons (P_Id, LastName, FirstName)
VALUES (5, 'Tjessem', 'Jakob')
INSERT INTO Persons (P_Id, LastName)
VALUES (5, 'Tjessem')


Delete statemet

The DELETE statement is used to delete rows or records in a table.
syntax:
DELETE FROM table_name
WHERE some_column=some_value
delete from employee where empno=6

Note: Notice the WHERE clause in the DELETE syntax.
The WHERE clause specifies which record or records that should be deleted.
If you omit the WHERE clause, all records will be deleted!
Delete All Rows
It is possible to delete all rows in a table without deleting the table.
This means that the table structure, attributes, and indexes will be intact:
DELETE FROM table_name
delete from employee
'DELETE'
DELETE FROM table_name
delete from persons1
DELETE FROM Persons
WHERE LastName='Tjessem' AND FirstName='Jakob'


Update statement

The UPDATE statement is used to update existing records in a table.
Syntax:
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Note: Notice the WHERE clause in the UPDATE syntax.
The WHERE clause specifies which record or records that should be updated.
If you omit the WHERE clause, all records will be updated!

update employee set salary = salary+5000 where empno = 4
UPDATE
UPDATE Persons
SET Address='Nissestien 67', City='Sandnes'
WHERE LastName='Tjessem' AND FirstName='Jakob'


DDL-Data Definition Language

DDL -Data Definition Language

Create,Alter,Drop statements.

Create statement

The CREATE TABLE statement is used to create a table in a database.
syntax:
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
....
....
)

create table employee(empno int,name varchar(30),desg char(3),salary int)

Alter statement
The ALTER TABLE statement is used to add, delete, or modify columns
in an existing table.
To add a column in a table, use the following syntax:

ALTER TABLE table_name ADD column_name datatype
Alter table employee add deptno int 'Adding a new field to the table'

To delete a column in a table, use the following syntax

(notice that some database systems dont allow deleting a column):
ALTER TABLE table_name DROP COLUMN column_name
Alter table employee drop column salary

To change the data type of a column in a table, use the following syntax:
ALTER TABLE table_name ALTER COLUMN column_name datatype
Alter table employee alter column salary money

Drop statement
The DROP TABLE statement is used to delete a table.
syntax:
DROP TABLE table_name
drop table employee

The DROP DATABASE statement is used to delete a database.
syntax:
DROP DATABASE database_name
drop database siva

Java Introduction-2


BENEFITS OF OOPS

• Modularity (separation of duties)

• Extensibility (responsive to future requirements)

• Modifiability (easy to make small changes)

• Flexibility (not cast in concrete)

• Maintainability (big savings)

• Reusability (don’t reinvent the wheel)

• Data abstraction (hidden data representation)

• Program encapsulation (operations bound to data)

• Software libraries (fixed reusable)

• Polymorphism (type-related generic operations)

Data abstraction

A powerful way to manage abstraction is through the use of hierarchical classifications.

This allows you to layer the semantics of complex systems, breaking them into more

manageable pieces. From the outside, the car is a single object. Once inside, you see

that the car consists of several subsystems: steering, brakes, sound system, seat belts,

and so on. In turn, each of these subsystems is made up of more specialized units.

• groups the pieces of data that describe some entity, so that programmers can manipulate that data as a unit advantages

• your programs become easier to read

• your programs become easier to reuse

• you can easily augment what a class provides

• you can easily improve the way that data are stored

The Three OOP Principles

  1. Encapsulation
  2. Inheritance
  3. Polymorphism

Encapsulation

Encapsulation is the mechanism that binds together code and the data it manipulates,

and keeps both safe from outside interference and misuse. One way to think about

encapsulation is as a protective wrapper that prevents the code and data from being

arbitrarily accessed by other code defined outside the wrapper. Access to the code

and data inside the wrapper is tightly controlled through a well-defined interface.

In Java the basis of encapsulation is the class. A class defines the structure and behavior

(data and code) that will be shared by a set of objects. Each object of a given class contains

the structure and behavior defined by the

class, as if it were stamped out by a mold in the shape of the class. For this reason, objects

are sometimes referred to as instances of a class. Thus, a class is a logical construct; an

object has physical reality.

When you create a class, you will specify the code and data that constitute that

class. Collectively, these elements are called members of the class. Specifically, the data

defined by the class are referred to as member variables or instance variables. The code

that operates on that data is referred to as member methods or just methods.

• Binds code & the data together

• The protective wrapper that prevents from the code & data from being arbitrarily accessed from outside.

• Mechanisms for hiding complexity is to be mark the variable or class as PROTECTED OR PUBLIC

Inheritance

Inheritance is the process by which one object acquires the properties of another object.

This is important because it supports the concept of hierarchical classification. As

mentioned earlier, most knowledge is made manageable by hierarchical (that is, top-down)

classifications.

Without the use of hierarchies, each object would need to define all of its characteristics explicitly.However, by use of inheritance, an object need only define those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

Derived class / Sub class

It is the class that has been created from an existing class.

Base class / Super class

It is the class from where the sub classes are derived

Polymorphism

Polymorphism (from the Greek, meaning “many forms”) is a feature that allows one

interface to be used for a general class of actions.

More generally, the concept of polymorphism is often expressed by the phrase “one

interface, multiple methods.” This means that it is possible to design a generic interface

to a group of related activities. This helps reduce complexity by allowing the same

interface to be used to specify a general class of action. It is the compiler’s job to select the

specific action (that is, method) as it applies to each situation.

• Mechanism that allows one name to be used for 2 or more related but technically different purposes.

• “ONE INTERFACE MULTIPLE METHODS”

• Appropriate method for the situation, is selected at Compile-time / Run-time.

Types of Polymorphism

• Compile-time Polymorphism = Early Binding = Static Binding

• Run-time Polymorphism = Late Binding = Dynamic Binding

STATIC POLYMORPHISM:

The overloaded function to be executed is selected at Compile time.

Examples:

Function Overloading

Operator Overloading

DYNAMIC POLYMORPHISM:

The function to be executed is selected at Run time

Example:

Virtual Functions

Garbage Collection and Finalize

Objects are garbage collected

• No explicit free

• Avoids dangling pointers and resulting type errors

Problem

• What if object has opened file or holds lock?

Solution

• finalize method, called by the garbage collector

– Before space is reclaimed, or when virtual machine exits

– Space overflow is not really the right condition to trigger

finalization when an object holds a lock...)

• Important convention: call super.

Note : System.gc( ) used call garbage collection manually

ENVIRONMENT & TOOLS

• Java Development Kit (JDK) comprises of the development tools & Java Standard Library (JSL)

• It includes a huge collection of class libraries called APIs.

Some of the important tools from JDK

  1. javac -- compiles Java Programs.
  2. java -- executes Java Programs.
  3. appletviewer -- execute Java Applets.
  4. javadoc -- creates HTML documentation for the Java Programs.

VIRTUAL MACHINE

• The NAME OF A CLASS (and not the name of a file) should be the parameter for Java Virtual Machine (JVM)

• The Java Compiler generates Byte code in .class file, which is interpreted by JVM, thus makes Java as Platform-independent.

• The corresponding .class file must be found in the list of directories in the CLASSPATH environment variable.

• The .class is loaded to the JVM and the execution starts by calling the method: public static void main(String args[])

COMMONLY USED API’s

Language support package

Util support package

IO package

Networking package

Applet package

AWT package

Swing package

SQL package

Java Introduction-1

The Creation of Java

Java was conceived by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and
Mike Sheridan at Sun Microsystems, Inc. in 1991. It took 18 months to develop the first
working version. This language was initially called “Oak” but was renamed “Java”
in 1995. Between the initial implementation of Oak in the fall of 1992 and the public
announcement of Java in the spring of 1995, many more people contributed to the design
and evolution of the language. Bill Joy, Arthur van Hoff, Jonathan Payne, Frank Yellin,
and Tim Lindholm were key contributors to the maturing of the original prototype.

• Java is an object-oriented language similar to C++.
• Simplified to eliminate C++ language features that cause common programming errors.
• Java source code files (files with a .java extension) are compiled into a format called bytecode (files with a .class extension).
• Class files can then be executed by a Java interpreter.
• Compiled Java code can run on most computers because Java interpreters and runtime environments, known as Java Virtual Machines (VMs), exist for most operating systems.
• Bytecode can also be converted directly into machine language instructions by a just-in-time compiler (JIT).

FEATURES OF JAVA
Simple & Powerful
Secure
Portable
Object-oriented
Robust
Multithreaded
Architecture-neutral
Interpreted & High Performance
Distributed
Dynamic

Simplicity
• Almost everything is an object
• All objects on heap, accessed through pointers
• No functions, no multiple inheritance, no go to, no
operator overloading, few automatic coercions
Portability and network transfer

• Bytecode interpreter on many platforms
Reliability and Safety

• Typed source and typed bytecode language
• Run-time type and bounds checks
 
Two Paradigms
  1. Procedure-oriented Programming
  2. Object-oriented Programming
As you know, all computer programs consist of two elements: code and data. Furthermore,
a program can be conceptually organized around its code or around its data. That is,
some programs are written around “what is happening” and others are written around
“who is being affected.” These are the two paradigms that govern how a program is
constructed.

The first way is called the process-oriented model. This approach characterizes
a program as a series of linear steps (that is, code). The process-oriented model can be
thought of as code acting on data. Procedural languages such as C employ this model to
considerable success.

The second approach, called object-oriented programming, was conceived.
Object-oriented programming organizes a program around its data (that is, objects) and a
set of well-defined interfaces to that data. An object-oriented program can be characterized
as data controlling access to code.

Procedure-oriented Programming
• Organizes a program around its procedure
• Emphasis of a program is on how to accomplish a task
• User has little, if any, control
• Follows bottom-up approach

Object-oriented Programming
• A program around its data & a set of well-defined interfaces to that data.
• Emphasis on data rather than procedure
• Programs are divided into Objects (relevant real-world objects )
• Data is hidden and cannot be accessed by external functions
• Objects can communicate with each other through functions
• New data and functions can be easily added whenever necessary
• User has a lot of control
• Follows bottom-up approach

SQL Server Tutorial-1 Introduction

SQL Introduction
SQL is a standard language for accessing and manipulating databases.

What is SQL?
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL is an ANSI (American National Standards Institute) standard.

What Can SQL do?
SQL can execute queries against a database
SQL can retrieve data from a database
SQL can insert records in a database
SQL can update records in a database
SQL can delete records from a database
SQL can create new databases
SQL can create new tables in a database
SQL can create stored procedures in a database
SQL can create views in a database
SQL can set permissions on tables, procedures, and views

Semicolon after SQL Statements?
Some database systems require a semicolon at the end of each SQL statement.

Semicolon is the standard way to separate each SQL statement in
database systems that allow more than one SQL statement to be executed
in the same call to the server.

We are using MS Access and SQL Server 2000 and
we do not have to put a semicolon after each SQL statement,
but some database programs force you to use it.

Character or Strings
The characters or strings must enclosed only in single Quatation.
ex:'siva','kumar','Imrankhan','Ranbhirkapoor'

Not case sensitive
SQL is not case sensitive. SELECT is the same as select.