Friday, 30 September 2016

JDBC in Java


JDBC: JDBC is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. It is working on all platforms.

JDBC stands for Java Data base Connectivity. It is a standard Java API. It establishes connectivity between the Java programming and  databases (ie mysql,mongoDB , sqllite).
It perform following tasks
1. Making a connection to a database.
2. Creating SQL statements.
3. Executing SQL  queries in the database.
4. Viewing & Modifying the resulting records.

JDBC is provides a complete set of interfaces. It allows for portable access to an underlying database.
Java is using to write different types of executables.
They are -
1. Java Applications
2. Java Applets
3. Java Servlets
4. Java Server Pages (JSPs)
5. Enterprise JavaBeans (EJBs).
All above mention executables are used with JDBC driver to access a database, and to store data.

JDBC Architecture
The JDBC API models support 1. Two-tier and 2. Three-tier processing models for database access. But in generally, JDBC Architecture consists of two layers −
1. JDBC API: This API provides the application-to-JDBC Manager connection.
2. JDBC Driver API: This API supports the JDBC Manager-to-Driver Connection.
1. The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases.
2. The JDBC driver manager ensures that the correct driver is used to access each data source. It is capable to support multiple concurrent drivers connected to multiple heterogeneous databases.

Following is the architectural diagram, which shows the location of the driver manager with respect to the JDBC drivers and the Java application −
JDBC Components
The JDBC API provides the following some interfaces and classes −
1. DriverManager : This class managing a list of database drivers. It matches the connection request from the java application with the proper database driver. To this, this is using communication sub protocol. The first driver that recognizes a certain sub protocol under JDBC will be used to establish a database Connection.
2. Driver               : This driver interface handles all the communications with the database server.
3. Connection       : This connection interface with all methods for contacting a database. The connection object represents communication context, i.e., all communication with database is through connection object only.
4. Statement          : By using objects created from this interface to submit the SQL statements to the database.
5. ResultSet          : These objects hold data retrieved from a database after you execute an SQL query using Statement objects. It acts as an iterator to allow you to move through its data.
6. SQLException   : This class handles any errors that occur in a database application.
SQL Quesries
Create Database
To create a new data database we using CREATE DATABASE syntax. The syntax is
                EX. CREATE DATABASE EMP;

Drop Database
To Delete a database.
The syntax is –

Create Table
To create a table in database.
The syntax is –
                     CREATE TABLE table_name;
        Ex. CREATE TABLE student;
Drop Table
        To delete a table.
        DROP TABLE table_name;
        Ex. DROP TABLE student;

INSERT Data into Table
            To insert data into table
                                                Syntax -  INSERT INTO table_name VALUES (column1, column2, ...);
                                                Ex. INSERT INTO Employees VALUES (100, 18, 'Zara', 'Ali');

Thursday, 29 September 2016

Copyright Act for Websites


Chapter1-Images and Text

Copyright Act is to say mine is mine.
If you have created some design, content or any product, Copyright Act helps you to save your design form being copied by someone. If someone does so you have the right to fight legally for the same.

There are many parameters on the basis of which Copyright Act is followed for IT industry.

Copyright for IMAGES
• Obtaining images for a web page:
One of the basic requirements of the World Wide Web is the ability to use good quality of images, graphics to convey the information to users in very effective manner.
A sophisticated, interactive and user-friendly graphical presentation is the USP of some of the Web's most popular sites.
Image can be created by drawing or by painting with the help of automated image creation programs and tools, instead of rebuilding the image from the existing one.
Creating image from scratch also helps to portray more innovative ideas without having certain boundaries or limitations.

• Taking images from third-parties:
 "Don't steal images”, is the simple rule followed universally. The moment an original image is stored on a hard drive for the first time, it gets protected by copyright. Any unauthorized copying of a such image is the violation of the creator's copyright, unless the use is not counted as limited exceptions to the copyright law, such as "fair use." In most cases, it is unlikely that the co-operation is of an image into a commercial web-site would be considered a fair use.

• Licensed images from the Internet: Licensed images can be used. Only if the creator or copyright holder allows the same with certain policies and conditions.
For Ex. Microsoft's "Internet Explorer" logo, may be copied, but if and only if copier accepts the terms of a license defining the acceptable uses of the image. Often such licenses provide that the copier cannot alter  the image in any way and may use the image as a link only to certain designated sites.

• Free Images off the Internet: Many of the web sites also provide images which are partially licenced but can be used by others. These images may be used in a web page, as the terms proposed by the image creator are followed. Typically, these sites only require that some type of credit is given to the creator or the author, including external to the author's site. However, there remains the possibility that the images were misappropriated at some point and were not original creations of the alleged author. In these cases, use of the images may infringe the copyright rights of the original author.
COPYRIGHT for Content and Text
• Developing content or text for a web page: The guidelines for content writing/development are similar to those for obtaining images. In fact original content, developed by the writer of the web-site, may be used without copyrights. As with images, appropriating Content/text from third-parties without permission is illegal, unless there is not some exceptions like “Fair Use”. Use of third-party Content/text is in accordance with to a license agreement should be followed with the terms of the license agreement.

COPYRIGHT for Code Scripts.

Developing Java Applets, JavaScript, and ActiveX scripts:
Just like Content and images, it is a violation of copyright law to appropriate coding or scripting from someone without permission of programmer or the creator. Many parties have made their scripts and applets open source. In these cases, use is allowed as long as any requirements are  asked by the programmer are followed.