INTRODUCTION The Online Shopping is a web based application intended for online retailers. The main objective of this application is to make it interactive and its ease of use. It would make searching, viewing and selection of a product easier. It contains a sophisticated search engine for user's to search for products specific to their needs. The search engine provides an easy and convenient way to search for products where a user can Search for a product interactively and the search engine would refine the products available based on the user’s input. The user can then view the complete specification of each product. They can also view the product reviews and also write their own reviews. The application also provides a drag and drop feature so that a user can add a product to the shopping cart by dragging the item in to the shopping cart. The main emphasis lies in providing a user friendly search engine for effectively showing the desired results and its drag and drop behavior. Services from a store that serves both walk-in customers and online customers. The online shopping system presents an online display of an order cutoff time and an associated delivery window for items selected by the customer. The system accepts the customer's submission of a purchase order for the item in response to a time of submission being before the order cutoff time. The online shopping system does not settle with a credit supplier of the customer until the item selected by the customer is picked from inventory but before it is delivered. Therefore, the customer can go online and make changes to the order. In addition, available service windows are presented to the customer as a function of customer selected order and service types; and further, the order picking is assigned in accordance with a picker's preference. 1.1 OFFLINE SHOPPING: • • A wide range of emotions involving various types of social interactions engages our five senses



Geared towards reducing the user’s cognitive burden through functional and performance based Website design heuristics Engages only 2 of our senses


1.4.1 Hardware Specification
Processor P IV RAM 250 MB Minimum Space Required 100 MB Display 16 bit color 1.4.2 Software Specification Operating Environment Win 2000/XP Platform .Net Framework & IIS Visual Studio 2008 Database SQL Server 2005




SYSTEM REQUIREMENT ANALYSIS 2.1 Information Gathering As the goal of the application is ease of use and to provide an interactive interface, extensive research has been done to gain an insight into the needs and behaviors of various users. The working of the application is made convenient and easy to use for the end user. Dr Andresen, Associate Professor, CIS provided regular feedback on the project. Users can be classified into two types based on their knowledge of the products that suit their needs. They can be classified as users who know about the product that would satisfy their needs and users who have to figure out the product that would satisfy their needs. Users who know about the product should be able to find the product easy with the click of a button. Such users can search for the product by using the product name as the search term. Users who have to figure out the product that would satisfy their needs could use a search term to find a list of products and then should be able to filter the results based on various parameters like product type, manufacturer, price range, platform supported etc. The users should be able to view the complete specification of the product and various images at different Zoom levels. The user should be able to read the customer reviews for the product and the ratings provided. They should be able to write their own reviews. They should be able to print out the specifications for a product or email the product page to a friends etc. To increase the ease of use the user should be able to add a product to the shopping cart by dragging a product and dropping it in the shopping cart. A user should 5

able to edit the contents of a shopping cart. They should be able to update the quantities of the products added to the cart and remove the products from the cart. The user should be able to remove the product from the shopping cart by dragging the product and dropping it outside the cart. The application can be made interactive by pop up messages when a product has been dropped in to the shopping cart or out of the shopping cart. The user can be notified if the cursor enters a drop area and the object that could be dropped. Also users are impatient making it important to load pages soon. Other than this, I did a lot of research on various other methods of building this application which and was able to incorporate a few stronger features into the application.The tools and controls used in the application are recommended ASP.NET controls and AJAX Toolkit controls which improves the navigation and usability and interactivity.

2.2 System Feasibility The system feasibility can be divided into the following sections: 2.2.1 Economic Feasibility The project is economically feasible as the only cost involved is having a computer with the minimum requirements mentioned earlier. For the users to access the application, the only cost involved will be in getting access to the Internet. 2.2.2 Technical Feasibility To deploy the application, the only technical aspects needed are mentioned below: Operating Environment Win 2000/XP


Platform .Net Framework & IIS Database SQL Server 2005

For Users: Internet Browser Internet Connection 2.2.3 Behavioral Feasibility The application requires no special technical guidance and all the views available in the application are self explanatory. The users are well guided with warning and failure messages for all the actions taken.

2.3 Existing System There are large numbers of commercial Online Shopping websites offering large number of products tailored to meet the shopping interests of large number of customers. These online marketplaces have thousands of products listed under various categories.  Problem: • The basic problems with the existing systems are the non-interactive environment they provide to the users. • The use of traditional user interfaces which make continuous post backs to the server; each post back makes a call to the server, gets the response and then


refreshes the entire web form to display the result. This scenario adds an extra trade off causing a delay in displaying the results • • A search engine that would display the results without allowing the users to further filter the results based on various parameters. Use of traditional and non user friendly interfaces that are hard to use

2.4 Proposed System Shopping has long been considered a recreational activity by many. Shopping online is no exception. The goal of this application is to develop a web based interface for online retailers. The system would be easy to use and hence make the shopping experience pleasant for the users. The goal of this application is

To develop an easy to use web based interface where users can search for products, view a complete description of the products and order the products.

A search engine that provides an easy and convenient way to search for products specific to their needs. The search engine would list a set of products based on the search term and the user can further filter the list based on various parameters.

An AJAX enabled website with the latest AJAX controls giving attractive and Interactive look to the web pages and prevents the annoying post backs.

Drag and Drop feature which would allow the users to add a product to or remove a product from the shopping cart by dragging the product in to the shopping cart or out of the shopping cart.


A user can view the complete specification of the product along with various images and also view the customer reviews of the product. They can also write their own reviews. Solution to the Existing System: • to allow the user to with The motive of this Online Shopping Web Application is the search tool and create different

combinatorial search criterion to perform exhaustive search. • Making the application AJAX enabled gets rid of these unnecessary delays letting the user to perform exhaustive search. The users of this application can easily feel the difference between the Ajax empowered user interfaces vs. traditional user interfaces. • • Provide Interactive interface through which a user can interact with different areas of application easily. A search engine that provides an easy and convenient way to search for product specific to their needs. The search engine would list a set of products based on the search term and the user can further filter the list based on various parameters. • Provide Drag and Drop feature thereby allowing the user to add products or remove products from the shopping cart by dragging the products in to or out of the shopping cart. Scope:

 • • • •

The current system can be extended to allow the users to create accounts and save products in to wish list. The users could subscribe for price alerts which would enable them to receive messages when price for products fall below a particular level. The current system is confined only to the shopping cart process. It can be extended to have a easy to use check out process. Users can have multiple shipping and billing information saved. During checkout they can use the drag and drop feature to select shipping and billing


information. 2.5 System Analysis After carefully analyzing the requirements and functionality of the web application, I had two important diagrams by the end of the analysis phase. They are the ER diagram and data flow diagram which were the basis for finding out entities and relationships between them, the flow of information. 2.6 ER Diagram

Figure 1.2: A ER Diagram


2.7 Data Flow Diagram

Figure 1.2: A Context Level Diagram


Figure 1.3: A First Level Diagram


Figure 1.4: A Second Level Diagram


2.8 Use Case Diagram

Figure 1.5: Use Case Diagram


2.9 Class Diagram

Figure 1.6: Class Diagram


2.7 Design 2.7.1 Design Goals • The design of the web application involves the design of the forms for listing the products, search for products, display the complete specification for the product, and design a shopping cart that is easy to use. • • • Design of an interactive application that enables the user to filter the products based on different parameters. Design of an application that has features like drag and drop etc. Design of application that decreases data transfers between the client and the server. 2.8 Description of Architectural Design In this context diagram, the information provided to and received from the ‘Online Shopping’ is identified. The arrows represent the information received or generated by the application. The closed boxes represent the set of sources and sinks of information. In the system, we can observe that the user interacts with the application through a graphical user interface. The inputs to the system are the Search and Filter criteria provided by the user and a new review written by the user. Also, the output is in the form of Repeater and grid views which present the users with list of Products available. The users can view complete specification, view Images and reviews by other users.

2.8.1 Architectural Context Diagram


Figure 1.7: Architectural Context Diagram
2.9 Procedural/Modular Approach Following are all the modules designed for the Online Shopping System. 2.9.1 Shop Products Module This module starts when the user visits the home page or when a user searches for a product by entering a search term. This part of the application includes displaying all the products that are available or the products that match the search term entered by the user. The user can then filter these products based on various parameters like manufacturer, product type, operating system supported or a price range. The user browse


through the products and each product would be displayed with an image and its features like operating system supported, number of user licenses and if it is a full version or an upgrade version. A user can add a product to the cart either by dragging the product and dropping it in the cart or by clicking a button. The user would be able to see the shopping cart summary. 2.9.2 Product Description Module This module starts when a user visits the product description page. A user can view various images of the product of different sizes. The use can see an enlarged image in a popup window. The user can view the complete specification of the product like its features, operating system supported, system requirements etc. A user can also view the manufacturer information and also information about rebates, exchange policies etc. A user can also view the reviews of the product. A user can also write a review for the product. 2.9.3 Shopping Cart Module This module starts when the user views the shopping cart. All the products that have been added to the shopping cart by the user are listed along with their price and the quantity. The total price of all the products added to cart is displayed. A user can edit the quantity of each product or remove the product from the shopping cart. A user can remove the product from the cart by clicking a button or by dragging the product and dropping it outside the cart. The total price changes accordingly when a user edits the quantity of a product or when a product is removed from the cart. 2.10 Technical Discussions The products can be filtered based on various parameters like Manufacturer, Product Type, Operating System supported etc. Initially it was decided to have the various list items predefined. But with time new manufacturers and product types could be added. So the values for the list of manufacturers and product types are loaded dynamically by retrieving from the database. Also it was decided initially to have a drop down list for price range and the user could select a price range from the ranges available. But this would limit 18

the user’s ability to filter the products based on different price ranges. Instead providing two text fields so that the user can enter their price range would give them more flexibility. A product could be added to a shopping cart by dragging it and dropping it in the cart area. Items in the cart could be removed by clicking a button. To maintain symmetry and ease of use products could be removed from the cart by dragging the product out of the cart. A product can be added to the cart by dragging it and dropping it in the cart. Initially it was decided that when a product is dropped in the cart the cart summary label could be updated on the client side without any call to the server and later the session variables (Shopping cart) could be updated. This would result in loss of information when the user loses internet connection. So when a product is dropped in the cart area a web service is called and this service updates the session variables for the shopping cart and the cart summary is recalculated and sent back to the client. This would improve the reliability of the application.





Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to byte code (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun made available most of their Java technologies as free software under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Class path. Java is an object-oriented programming language developed initially by James Gosling and colleagues at Sun Microsystems. The language, initially called Oak (named after the oak trees outside Gosling's office), was intended to replace C++, although the feature set better resembles that of Objective C. Java should not be confused with JavaScript, which shares only the name and a similar C-like syntax. "Java" generally refers to a combination of three things: the Java programming language (a high-level, object-oriented programming language); the Java Virtual Machine (a high-performance virtual machine that executes byte codes on a specific computing platform, typically abbreviated JVM); and the Java platform, a JVM running compiled Java byte codes, usually calling on a set of standard libraries such as those provided by Java Standard Edition (SE) or Enterprise Edition (EE). Though coupled by design, the language does not imply the JVM, and vice versa. History James Gosling initiated the Java language project in June 1991 for use in one of his many set-top box projects. The language, initially called Oak after an oak tree that stood outside


Gosling's office, also went by the name Green and ended up later renamed as Java, from a list of random words. Gosling aimed to implement a virtual machine and a language that had a familiar C/C++ style of notation. Sun released the first public implementation as Java 1.0 in 1995. It promised "Write Once, Run anywhere" (WORA), providing no-cost run-times on popular platforms. Fairly secure and featuring configurable security, it allowed network- and file-access restrictions. Major web browsers soon incorporated the ability to run Java applets within web pages, and Java quickly became popular. With the advent of Java 2 (released initially as J2SE 1.2 in December 1998), new versions had multiple configurations built for different types of platforms. For example, J2EE targeted enterprise applications and the greatly strippeddown version J2ME for mobile applications. J2SE designated the Standard Edition. In 2006, for marketing purposes, Sun renamed new J2 versions as Java EE, Java ME, and Java SE, respectively. In 1997, Sun Microsystems approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. [8] Java remains a de facto standard, controlled through the Java Community Process.[9] At one time, Sun made most of its Java implementations available without charge, despite their proprietary software status. Sun generated revenue from Java through the selling of licenses for specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Runtime Environment (JRE) (a subset of the SDK); the primary distinction involves the JRE's lack of the compiler, utility programs, and header files. On 13 November 2006, Sun released much of Java as free and open source software under the terms of the GNU General Public License (GPL). On 8 May 2007 Sun finished the process, making all of Java's core code available under free software / open-source distribution terms, aside from a small portion of code to which Sun did not hold the copyright.


Primary goals There were five primary goals in the creation of the Java language: 1. It should be "simple, object oriented and familiar". 2. It should be "robust and secure". 3. It should be "architecture neutral and portable". 4. It should execute with "high performance". 5. It should be "interpreted, threaded, and dynamic".

Java Platform One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any supported hardware/operating-system platform. One should be able to write a program once, compile it once, and run it anywhere. This is achieved by compiling the Java language code, not to machine code but to Java byte code – instructions analogous to machine code but intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a Web browser for Java applets. Standardized libraries provide a generic way to access host specific features such as graphics, threading and networking. In some JVM versions, byte code can be compiled to native code, either before or during program execution, resulting in faster execution. A major benefit of using byte code is porting. However, the overhead of interpretation means that interpreted programs almost always run more slowly than programs compiled to native executables would, and Java suffered a reputation for poor performance. This gap


has been narrowed by a number of optimization techniques introduced in the more recent JVM implementations. One such technique, known as just-in-time (JIT) compilation, translates Java byte code into native code the first time that code is executed, then caches it. These results in a program that starts and executes faster than pure interpreted code can, at the cost of introducing occasional compilation overhead during execution. More sophisticated VM also use dynamic recompilation, in which the VM analyzes the behavior of the running program and selectively recompiles and optimizes parts of the program. Dynamic recompilation can achieve optimizations superior to static compilation because the dynamic compiler can base optimizations on knowledge about the runtime environment and the set of loaded classes, and can identify hot spots - parts of the program, often inner loops, that take up the most execution time. JIT compilation and dynamic recompilation allow Java programs to approach the speed of native code without losing portability. Another technique, commonly known as static compilation, or ahead-of-time (AOT) compilation, is to compile directly into native code like a more traditional compiler. Static Java compilers translate the Java source or byte code to native object code. This achieves good performance compared to interpretation, at the expense of portability; the output of these compilers can only be run on a single architecture. AOT could give Java something close to native performance, yet it is still not portable since there are no compiler directives, and all the pointers are indirect with no way to micro manage garbage collection. Java's performance has improved substantially since the early versions, and performance of JIT compilers relative to native compilers has in some tests been shown to be quite similar. The performance of the compilers does not necessarily indicate the performance of the compiled code; only careful testing can reveal the true performance issues in any system. One of the unique advantages of the concept of a runtime engine is that even the most serious errors (exceptions) in a Java program should not 'crash' the system under any


circumstances, provided the JVM itself is properly implemented. Moreover, in runtime engine environments such as Java there exist tools that attach to the runtime engine and every time that an exception of interest occurs they record debugging information that existed in memory at the time the exception was thrown (stack and heap values). These Automated Exception Handling tools provide 'root-cause' information for exceptions in Java programs that run in production, testing or development environments. Such precise debugging is much more difficult to implement without the run-time support that the JVM offers.

Implementations Sun Microsystems officially licenses the Java Standard Edition platform for Microsoft Windows, Linux, Mac OS X, and Solaris. Through a network of third-party vendors and licensees, alternative Java environments are available for these and other platforms. Sun's trademark license for usage of the Java brand insists that all implementations be "compatible". This resulted in a legal dispute with Microsoft after Sun claimed that the Microsoft implementation did not support RMI or JNI and had added platform-specific features of their own. Sun sued in 1997 and in 2001 won a settlement of $20 million as well as a court order enforcing the terms of the license from Sun. As a result, Microsoft no longer ships Java with Windows, and in recent versions of Windows, Internet Explorer cannot support Java applets without a third-party plug in. Sun, and others, has made available free Java run-time systems for those and other versions of Windows. Platform-independent Java is essential to the Java EE strategy, and an even more rigorous validation is required to certify an implementation. This environment enables portable server-side applications, such as Web services, serviette, and Enterprise JavaBeans, as well as with embedded systems based on OSGi, using Embedded Java environments. Through the new Glassfish project, Sun is working to create a fully functional, unified open-source implementation of the Java EE technologies.


Sun also distributes a superset of the JRE called the Java Development Kit (commonly known as the JDK), which includes development tools such as the Java compiler, Java doc, Jar and debugger.

Automatic memory management Java uses an automatic garbage collector to manage memory in the object lifecycle. The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use. Once no references to an object remain, the unreachable object becomes eligible to be freed automatically by the garbage collector. Something similar to a memory leak may still occur if a programmer's code holds a reference to an object that is no longer needed, typically when objects that are no longer needed are stored in containers that are still in use. If methods for a nonexistent object are called, a "null pointer exception" is thrown. One of the ideas behind Java's automatic memory management model is that programmers be spared the burden of having to perform manual memory management. In some languages memory for the creation of objects is implicitly allocated on the stack or explicitly allocated and deal located from the heap. Either way the responsibility of managing memory resides with the programmer. If the program does not deal locate an object, a memory leak occurs. If the program attempts to access or deal locate memory that has already been deal located, the result is undefined and difficult to predict, and the program is likely to become unstable and/or crash. This can be partially remedied by the use of smart pointers, but these add overhead and complexity. Garbage collection may happen at any time. Ideally, it will occur when a program is idle. It is guaranteed to be triggered if there is insufficient free memory on the heap to allocate a new object; this can cause a program to stall momentarily. Where performance or response time is important, explicit memory management and object pools are often used.


Java does not support C/C++ style pointer arithmetic, where object addresses and unsigned integers (usually long integers) can be used interchangeably. This allows the garbage collector to relocate referenced objects, and ensures type safety and security. As in C++ and some other object-oriented languages, variables of Java's primitive types are not objects. Values of primitive types are either stored directly in fields (for objects) or on the stack (for methods) rather than on the heap, as commonly true for objects (but see Escape analysis). This was a conscious decision by Java's designers for performance reasons. Because of this, Java was not considered to be a pure object-oriented programming language. However, as of Java 5.0, auto boxing enables programmers to proceed as if primitive types are instances of their wrapper classes.

Syntax The syntax of Java is largely derived from C++. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object oriented language. All code is written inside a class and everything is an object, with the exception of the intrinsic data types (ordinal and real numbers, Boolean values, and characters), which are not classes for performance reasons. Java suppresses several features (such as operator overloading and multiple inheritance) for classes in order to simplify the language and to prevent possible errors and anti-pattern design. Java uses the same commenting methods as C++. There are two different styles of comment: a single line style marked with two forward slashes, and a multiple line style opened with a forward slash asterisk (/*) and closed with an asterisk forward slash (*/). Example: //This is an example of a single line comment using two forward slashes /* This is an example of a multiple line comment using the forward slash


and asterisk. This type of comment can be used to hold a lot of information but it is very important to remember to close the comment. */ Examples Hello world The traditional Hello world program can be written in Java as: /* * Outputs "Hello, world!" and then exits */ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, world!"); } } By convention, source files are named after the public class they contain, appending the suffix .java, for example, Hello World. Java It must first be compiled into byte code, using a Java compiler, producing a file named Hello World. Class only then can it be executed, or 'launched'. The java source file may only contain one public class but can contain multiple classes with less than public access and any number of public inner classes. A class that is declared private may be stored in any .java file. The compiler will generate a class file for each class defined in the source file. The name of the class file is the name of the class, with .class appended. For class file generation, anonymous classes are treated as if their name was the concatenation of the name of their enclosing class, a $, and an integer. The keyword public denotes that a method can be called from code in other classes, or that a class may be used by classes outside the class hierarchy. The class hierarchy is related to the name of the directory in which the .java file is. The keyword static in front of a method indicates a static method, which is associated only with the class and not with any specific instance of that class. Only static methods can be


invoked without a reference to an object. Static methods cannot access any method variables that are not static. The keyword void indicates that the main method does not return any value to the caller. If a Java program is to exit with an error code, it must call System.exit() explicitly. The method name "main" is not a keyword in the Java language. It is simply the name of the method the Java launcher calls to pass control to the program. Java classes that run in managed environments such as applets and Enterprise Java Beans do not use or need a main() method. A java program may contain multiple classes that have main methods, which means that the VM needs to be explicitly told which class to launch from. The main method must accept an array of String objects. By convention, it is referenced as args although any other legal identifier name can be used. Since Java 5, the main method can also use variable arguments, in the form of public static void main(String... args), allowing the main method to be invoked with an arbitrary number of String arguments. The effect of this alternate declaration is semantically identical (the args parameter is still an array of String objects), but allows an alternate syntax for creating and passing the array. The Java launcher launches Java by loading a given class (specified on the command line or as an attribute in a JAR) and starting its public static void main(String[]) method. Standalone programs must declare this method explicitly. The String [] args parameter is an array of String objects containing any arguments passed to the class. The parameters to main are often passed by means of a command line. Printing is part of a Java standard library: The System class defines a public static field called out. The out object is an instance of the PrintStream class and provides many methods for printing data to standard out, including println(String) which also appends a new line to the passed string. The string "Hello world!" is automatically converted to a String object by the compiler.


A more comprehensive example // import javax.swing.JOptionPane; public class OddEven { // "input" is the number that the user gives to the computer private int input; // a whole number("int" means integer) /* * This is the constructor method. It gets called when an object of the OddEven type * is being created. */ public OddEven() { //Code not shown } // This is the main method. It gets called when this class is run through a Java interpreter. public static void main(String[] args) { /* * This line of code creates a new instance of this class called "number" (also known as an * Object) and initializes it by calling the constructor. The next line of code calls * the "showDialog()" method, which brings up a prompt to ask you for a number */ OddEven number = new OddEven(); number.showDialog(); } public void showDialog() { /* * "try" makes sure nothing goes wrong. If something does,


* the interpreter skips to "catch" to see what it should do. */ try { /* * The code below brings up a JOptionPane, which is a dialog box * The String returned by the "showInputDialog()" method is converted into * an integer, making the program treat it as a number instead of a word. * After that, this method calls a second method, calculate() that will * display either "Even" or "Odd." */ input = new Integer(JOptionPane.showInputDialog("Please Enter A Number")); calculate(); } catch (NumberFormatException e) { /* * Getting in the catch block means that there was a problem with the format of * the number. Probably some letters were typed in instead of a number. */ System.err.println("ERROR: Invalid input. Please type in a numerical value."); } } /* * When this gets called, it sends a message to the interpreter. * The interpreter usually shows it on the command prompt (For Windows users) * or the terminal (For Linux users).(Assuming it's open) */ private void calculate() { if (input % 2 == 0) { System.out.println("Even"); } else { System.out.println("Odd");


} } }

The import statement imports the J Option Pane class from the javax. Swing package. The Odd Even class declares a single private field of type int named input. Every instance of the Odd Even class has its own copy of the input field. The private declaration means that no other class can access (read or write) the input field.

Odd Even () is a public constructor. Constructors have the same name as the enclosing classes they are declared in, and unlike a method, have no return type. A constructor is used to initialize an object that is a newly created instance of the class.

Calculate () method is declared without the static keyword. This means that the method is invoked using a specific instance of the Odd Even class. (The reference used to invoke the method is passed as an undeclared parameter of type Odd Even named this.) The method tests the expression input % 2 == 0 using the ‘if’ keyword to see if the remainder of dividing the input field belonging to the instance of the class by two is zero. If this expression is true, then it prints Even; if this expression is false it prints Odd. (The input field can be equivalently accessed as this. input, which explicitly uses the undeclared this parameter.)

Odd Even number = new Odd Even (); declares a local object reference variable in the main method named number. This variable can hold a reference to an object of type Odd Even. The declaration initializes number by first creating an instance of the Odd Even class, using the new keyword and the Odd Even() constructor, and then assigning this instance to the variable.

The statement number.showDialog(); calls the calculate method. The instance of Odd Even object referenced by the number local variable is used to invoke the method and passed as the undeclared this parameter to the calculate method.

Input = new Integer (JOptionPane.showInputDialog("Please Enter A Number")); is a statement that converts the type of String to the primitive type int by taking advantage of the wrapper class Integer.


Special classes Applet Java applets are programs that are embedded in other applications, typically in a Web page displayed in a Web browser. // import javax.swing.JApplet; import java.awt.Graphics; public class Hello extends JApplet { public void paintComponent(Graphics g) { g.drawString("Hello, world!", 65, 95); } } The import statements direct the Java compiler to include the javax.swing.JApplet and java.awt.Graphics classes in the compilation. The import statement allows these classes to be referenced in the source code using the simple class name (i.e. JApplet) instead of the fully qualified class name (i.e. javax.swing.JApplet). The Hello class extends (subclasses) the JApplet (Java Applet) class; the JApplet class provides the framework for the host application to display and control the lifecycle of the applet. The JApplet class is a JComponent (Java Graphical Component) which provides the applet with the capability to display a graphical user interface (GUI) and respond to user events. The Hello class overrides the paintComponent(Graphics) method inherited from the Container superclass to provide the code to display the applet. The paint() method is passed a Graphics object that contains the graphic context used to display the applet. The paintComponent() method calls the graphic context drawString(String, int, int) method to


display the "Hello, world!" string at a pixel offset of (65, 95) from the upper-left corner in the applet's display. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ""> <!-- Hello.html --> <html> <head> <title>Hello World Applet</title> </head> <body> <applet code="Hello" width="200" height="200"> </applet> </body> </html> An applet is placed in an HTML document using the <applet> HTML element. The applet tag has three attributes set: code="Hello" specifies the name of the JApplet class and width="200" height="200" sets the pixel width and height of the applet. Applets may also be embedded in HTML using either the object or embed element, although support for these elements by Web browsers is inconsistent. However, the applet tag is deprecated, so the object tag is preferred where supported. The host application, typically a Web browser, instantiates the Hello applet and creates an Applet Context for the applet. Once the applet has initialized itself, it is added to the AWT display hierarchy. The paint method is called by the AWT event dispatching thread whenever the display needs the applet to draw itself. Servlet Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. Servlets are server-side Java EE components that generate responses (typically HTML


pages) to requests (typically HTTP requests) from clients. A servlet can almost be thought of as an applet that runs on the server side—without a face. // import*; import javax.servlet.*; public class Hello extends GenericServlet { public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); final PrintWriter pw = response.getWriter(); pw.println("Hello, world!"); pw.close(); } } The import statements direct the Java compiler to include all of the public classes and interfaces from the and javax.servlet packages in the compilation. The Hello class extends the GenericServlet class; the GenericServlet class provides the interface for the server to forward requests to the servlet and control the servlet's lifecycle. The Hello class overrides the service(Servlet Request, Servlet Response) method defined by the Servlet interface to provide the code for the service request handler. The service() method is passed a Servlet Request object that contains the request from the client and a Servlet Response object used to create the response returned to the client. The service() method declares that it throws the exceptions Servlet Exception and IO Exception if a problem prevents it from responding to the request. The set Content Type(String) method in the response object is called to set the MIME content type of the returned data to "text/html". The getWriter() method in the response returns a PrintWriter object that is used to write the data that is sent to the client. The println(String) method is called to write the "Hello, world!" string to the response and then


the close() method is called to close the print writer, which causes the data that has been written to the stream to be returned to the client.

JavaServer Page JavaServer Pages (JSPs) are server-side Java EE components that generate responses, typically HTML pages, to HTTP requests from clients. JSPs embed Java code in an HTML page by using the special delimiters <% and %>. A JSP is compiled to a Java servlet, a Java application in its own right, the first time it is accessed. After that, the generated servlet creates the response.

Swing application Swing is a graphical user interface library for the Java SE platform. It is possible to specify a different look and feel through the pluggable look and feel system of Swing. Clones of Windows, GTK and Motif are supplied by Sun. Apple also provides an Aqua look and feel for Mac OS X. Where prior implementations of these looks and feels may have been considered lacking, Swing in Java SE 6 addresses this problem by using more native widget drawing routines of the underlying platforms. This example Swing application creates a single window with "Hello, world!" inside: // (Java SE 5) import java.awt.BorderLayout; import javax.swing.*; public class Hello extends JFrame { public Hello() { super("hello"); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setLayout(new BorderLayout()); add(new JLabel("Hello, world!"));


pack(); } public static void main(String[] args) { new Hello().setVisible(true); } } The first import statement directs the Java compiler to include the BorderLayout class from the java.awt package in the compilation; the second import includes all of the public classes and interfaces from the javax.swing package. The Hello class extends the JFrame class; the JFrame class implements a window with a title bar and a close control. The Hello() constructor initializes the frame by first calling the superclass constructor, passing the parameter "hello", which is used as the window's title. It then calls the setDefaultCloseOperation(int) method inherited from JFrame to set the default operation when the close control on the title bar is selected to WindowConstants.EXIT_ON_CLOSE — this causes the J Frame to be disposed of when the frame is closed (as opposed to merely hidden), which allows the JVM to exit and the program to terminate. Next, the layout of the frame is set to a Border Layout; this tells Swing how to arrange the components that will be added to the frame. A J Label is created for the string "Hello, world!" and the add(Component) method inherited from the Container super class is called to add the label to the frame. The pack () method inherited from the Window super class is called to size the window and lay out its contents, in the manner indicated by the Border Layout. The main() method is called by the JVM when the program starts. It instantiates a new Hello frame and causes it to be displayed by calling the set Visible(Boolean) method inherited from the Component super class with the Boolean parameter true. Once the frame is displayed, exiting the main method does not cause the program to terminate because the AWT event dispatching thread remains active until all of the Swing top-level windows have been disposed.


Generics In 2004 generics were added to the Java language, as part of J2SE 5.0. Prior to the introduction of generics, each variable declaration had to be of a specific type. For container classes, for example, this is a problem because there is no easy way to create a container that accepts only specific types of objects. Either the container operates on all subtypes of a class or interface, usually Object, or a different container class has to be created for each contained class. Generics allow compile-time type checking without having to create a large number of container classes, each containing almost identical code. Class libraries

Java libraries are the compiled byte codes of source code developed by the JRE implementer to support application development in Java. Examples of these libraries are:

The core libraries, which include:

Collection libraries that implement data structures such as lists, dictionaries, trees and sets XML Processing (Parsing, Transforming, Validating) libraries Security Internationalization and localization libraries

   o

The integration libraries, which allow the application writer to communicate with external systems. These libraries include:
 

The Java Database Connectivity (JDBC) API for database access Java Naming and Directory Interface (JNDI) for lookup and discovery RMI and CORBA for distributed application development JMX for managing and monitoring applications The (heavyweight, or native) Abstract Window Toolkit (AWT), which provides GUI components, the means for laying out those

  o

User Interface libraries, which include:


components and the means for handling events from those components

The (lightweight) Swing libraries, which are built on AWT but provide (non-native) implementations of the AWT widget APIs for audio capture, processing, and playback

 •

A platform dependent implementation of Java virtual machine (JVM) that is the means by which the byte codes of the Java libraries and third party applications are executed

• •

Plug-in, which enable applets to be run in Web browsers Java Web Start, which allows Java applications to be efficiently distributed to end users across the Internet Licensing and documentation. Java is generally thought of in terms of three platforms: Standard Edition

(SE), Enterprise Edition (EE), and Micro Edition (ME). Each describes the combination of a language version, a set of standard libraries, and a virtual machine to execute the code. EE is a superset of SE--any EE application can assume the existence of all of the SE libraries--and EE's use of the language is identical to SE's. Because of the limitations of small devices like phones and seta top box, Java Micro Edition differs significantly from its siblings. It is not a subset of SE (as SE is of EE), as some of its libraries exist only in Micro Edition. Moreover, ME eliminate some language features, such as the float primitive and Float class, reflecting the computing limitations of the platforms it runs on. Requiring different tools than SE and EE, and with profound differences in devices that makes code portability far less realistic in the micro space, many Java developers see ME as utterly alien.

The Java Virtual Machine At some point, Java source needs to become platform-native executable code. This typically requires a two-step process: the developer compiles his or her source into Java byte code, and then a Java Virtual Machine (JVM) converts this into native code for the


host platform. This latter step originally was performed by interpretation--taking each JVM instruction and converting it on the fly to one or more native instructions. Later, just-intime (JIT) compilers converted all of a Java program from JVM byte code to native code as the program started up. In the modern era, there are multiple approaches. Swing (Java) Swing is a GUI toolkit for Java. It is one part of the JavaFoundation Classes (JFC). Swing includes graphical user interface (GUI) widgets such as text boxes, buttons, splitpanes, and tables.

Swing widgets provide more sophisticated GUI components The earlier Abstract Window Toolkit. Since they are written in pure Java, they run the same on all platforms, unlike the AWT which is tied to the underlying platform's windowing system. Swing supports pluggable look and feel – not by using the native platform's facilities, but by roughly emulating them. This means you can get any supported look and feel on any platform. The disadvantage of lightweight components is slower execution. The advantage is uniform behavior on all platforms. Main New Features
• •

Lightweight. Not built on native window-system windows. Much bigger set of built-in controls. Trees, image buttons, tabbed panes, sliders, toolbars, color choosers, tables, text areas to display HTML or RTF, etc. Much more customizable. Can change border, text alignment, or add image to almost any control. Can customize how minor features are drawn. Can separate internal representation from visual appearance.

"Pluggable" look and feel. Can change look and feel at runtime, or design own look and feel. Many miscellaneous new features. Double-buffering built in, tool tips, dockable tool bars, keyboard accelerators, custom cursors, etc.


SQL Server2005: A Relational Data Base Management System (RDBMS) From Sybase Corporation, SQL Server was designed for client/server use and is accessed by applications using SQL. It runs on OS/2, Windows NT, NetWare servers, VAXen, and UNIX workstations. Generically, any database management system (DBMS) that can respond to queries from client machines formatted in the SQL language. When capitalized, the term generally refers to either of two database management products from Sybase and Microsoft. A Microsoft database technology more powerful than, and compatible with, Microsoft Access. Organizations with existing SQL Server databases that function well may elect to create new Access applications as front ends that link to their SQL Server tables. These hybrid projects extend existing systems or add new IT capacity to an organization that wants to make their existing information useful in new ways. Microsoft SQL Server is a relational model database server produced by Microsoft. Its primary query languages are T-SQL and ANSI SQL. History The code base for MS SQL Server (prior to version 7.0) originated in Sybase SQL Server, and was Microsoft's entry to the enterprise-level database market, competing against Oracle, IBM, and, later, Sybase itself. Microsoft, Sybase and Ashton-Tate originally teamed up to create and market the first version named SQL Server 1.0 for OS/2 (about 1989) which was essentially the same as Sybase SQL Server 3.0 on Unix, VMS, etc. Microsoft SQL Server 4.2 was shipped around 1992 (available bundled with Microsoft OS/2 version 1.3). Later Microsoft SQL Server 4.21 for Windows NT was released at the same time as Windows NT 3.1. Microsoft SQL Server v6.0 was the first version designed for NT, and did not include any direction from Sybase.


About the time Windows NT was released, Sybase and Microsoft parted ways and each pursued their own design and marketing schemes. Microsoft negotiated exclusive rights to all versions of SQL Server written for Microsoft operating systems. Later, Sybase changed the name of its product to Adaptive Server Enterprise to avoid confusion with Microsoft SQL Server. Until 1994, Microsoft's SQL Server carried three Sybase copyright notices as an indication of its origin. Since parting ways, several revisions have been done independently. SQL Server 7.0 was a rewrite from the legacy Sybase code. It was succeeded by SQL Server 2000, which was the first edition to be launched in a variant for the IA-64 architecture. In the eight years since release of Microsoft's previous SQL Server product (SQL Server 2000), advancements have been made in performance, the client IDE tools, and several complementary systems that are packaged with SQL Server 2005. These include: an ETL tool (SQL Server Integration Services or SSIS), a Reporting Server, an OLAP and data mining server (Analysis Services), and several messaging technologies, specifically Service Broker and Notification Services.

SQL Server 2005 SQL Server 2005 (codenamed Yukon), released in October 2005, is the successor to SQL Server 2000. It included native support for managing XML data, in addition to relational data. For this purpose, it defined an xml data type that could be used either as a data type in database columns or as literals in queries. XML columns can be associated with XSD schemas; XML data being stored is verified against the schema. XML is converted to an internal binary data type before being stored in the database. Specialized indexing methods were made available for XML data. XML data is queried using XQuery; SQL Server 2005 added some extensions to the T-SQL language to allow embedding XQuery queries in TSQL. In addition, it also defines a new extension to XQuery, called XML DML that allows query-based modifications to XML data. SQL Server 2005 also allows a database server to


be exposed over web services using TDS packets encapsulated within SOAP (protocol) requests. When the data is accessed over web services, results are returned as XML. For relational data, T-SQL has been augmented with error handling features and support for recursive queries. SQL Server 2005 has also been enhanced with new indexing algorithms and better error recovery systems. Data pages are check summed for better error resiliency, and optimistic concurrency support has been added for better performance. Permissions and access control have been made more granular and the query processor handles concurrent execution of queries in a more efficient way. Partitions on tables and indexes are supported natively, so scaling out a database onto a cluster is easier. SQL CLR was introduced with SQL Server 2005 to let it integrate with the .NET Framework. SQL Server 2005 introduced "MARS" (Multiple Active Results Sets), a method of allowing usage of database connections for multiple purposes.

SQL Server 2008 The current version of SQL Server, SQL Server 2008, (code-named "Katmai",) was released (RTM) on August 6, 2008 and aims to make data management self-tuning, self organizing, and self maintaining with the development of SQL Server Always On technologies, to provide near-zero downtime. SQL Server 2008 will also include support for structured and semi-structured data, including digital media formats for pictures, audio, video and other multimedia data. In current versions, such multimedia data can be stored as BLOBs (binary large objects), but they are generic bitstreams. Intrinsic awareness of multimedia data will allow specialized functions to be performed on them. According to Paul Flessner, senior Vice President, Server Applications, Microsoft Corp., SQL Server 2008 can be a data storage backend for different varieties of data: XML, email, time/calendar, file, document, spatial, etc as well as perform search, query, analysis, sharing, and synchronization across all data types.


Other new data types include specialized date and time types and a Spatial data type for location-dependent data. Better support for unstructured and semi-structured data is provided using the new FILESTREAM data type, which can be used to reference any file stored on the file system. Structured data and metadata about the file is stored in SQL Server database, whereas the unstructured component is stored in the file system. Such files can be accessed both via Win32 file handling APIs as well as via SQL Server using TSQL; doing the latter accesses the file data as a BLOB. Backing up and restoring the database backs up or restores the referenced files as well. SQL Server 2008 also natively supports hierarchical data, and includes T-SQL constructs to directly deal with them, without using recursive queries. The Full-Text Search functionality has been integrated with the database engine, which simplifies management and improves performance. Spatial data will be stored in two types. A "Flat Earth" (GEOMETRY or planar) data type represents geospatial data which has been projected from its native, spherical, coordinate system into a plane. A "Round Earth" data type (GEOGRAPHY) uses an ellipsoidal model in which the Earth is defined as a single continuous entity which does not suffer from the singularities such as the international dateline, poles, or map projection zone "edges". Approximately 70 methods are available to represent spatial operations for the Open Geospatial Consortium Simple Features for SQL, Version 1.1. SQL Server includes better compression features, which also helps in improving scalability. It also includes Resource Governor that allows reserving resources for certain users or workflows. It also includes capabilities for transparent encryption of data as well as compression of backups. SQL Server 2008 supports the ADO.NET Entity Framework and the reporting tools, replication, and data definition will be built around the Entity Data Model.[13] SQL Server Reporting Services will gain charting capabilities from the integration of the data visualization products from Dundas Data Visualization Inc., which was acquired by Microsoft. On the management side, SQL Server 2008 includes the Declarative Management Framework which allows configuring policies and constraints, on


the entire database or certain tables, declaratively. The version of SQL Server Management Studio included with SQL Server 2008 supports IntelliSense for SQL queries against a SQL Server 2008 Database Engine. SQL Server 2008 also makes the databases available via Windows PowerShell providers and management functionality available as Cmdlets, so that the server and all the running instances can be managed from Windows PowerShell.

SQL Server 2008 R2 SQL Server 2008 R2 (formerly codenamed SQL Server "Kilimanjaro") was announced at TechEd 2009. SQL Server 2008 R2 adds certain features to SQL Server 2008 including master data management system branded as Master Data Services, a centralized console to manage multiple SQL Server instances, and support for more than 64 logical processors. Microsoft makes SQL Server available in multiple versions, with different feature sets and targeting different users. These versions are: SQL Server Compact Edition (SQL CE) The compact edition is an embedded database engine. Unlike the other versions of SQL Server, the SQL CE engine is based on SQL Mobile (initially designed for use with handheld devices) and does not share the same binaries. Due to its small size (1MB DLL footprint), it has a markedly reduced feature set compared to the other editions. For example, it supports a subset of the standard data types, does not support stored procedures or Views or multiple-statement batches (among other limitations). It is limited to 4GB maximum database size and cannot be run as a Windows service, Compact Edition must be hosted by the application using it. The 3.5 version includes considerable work that supports ADO.NET Synchronization Services. SQL Server Developer Edition SQL Server Developer Edition includes the same features as SQL Server Enterprise Edition, but is limited by the license to be only used as a development and test system, and


not as production server. This version is available to download by students free of charge as a part of Microsoft's DreamSpark program. SQL Server 2005 Embedded Edition (SSEE) SQL Server 2005 Embedded Edition is a specially configured named instance of the SQL Server Express database engine which can be accessed only by certain Windows Services.

SQL Server Enterprise Edition SQL Server Enterprise Edition is the full-featured version of SQL Server, including both the core database engine and add-on services, while including a range of tools for creating and managing a SQL Server cluster. SQL Server Evaluation Edition SQL Server Evaluation Edition, also known as the Trial Edition, has all the features of the Enterprise Edition, but is limited to 180 days, after which the tools will continue to run, but the server services will stop. SQL Server Express Edition SQL Server Express Edition is a scaled down, free edition of SQL Server, which includes the core database engine. While there are no limitations on the number of databases or users supported, it is limited to using one processor, 1 GB memory and 4 GB database files. The entire database is stored in a single .mdf file, and thus making it suitable for XCOPY deployment. It is intended as a replacement for MSDE. Two additional versions provide a superset of features not in the original Express Edition. The first is SQL Server Express with Tools, which includes SQL Server Management Studio Basic. SQL Server Express with Advanced Services adds full-text search capability and reporting services. SQL Server Fast Track


SQL Server Fast Track is specifically for enterprise-scale data warehousing storage and business intelligence processing, and runs on reference-architecture hardware that is optimized for Fast Track. SQL Server Standard Edition SQL Server Standard edition includes the core database engine, along with the stand-alone services. It differs from Enterprise edition in that it supports fewer active instances (number of nodes in a cluster) and does not include some high-availability functions such as hot-add memory (allowing memory to be added while the server is still running), and parallel indexes.

Architecture Protocol layer Protocol layer implements the external interface to SQL Server. All operations that can be invoked on SQL Server are communicated to it via a Microsoft-defined format, called Tabular Data Stream (TDS). TDS is an application layer protocol, used to transfer data between a database server and a client. Initially designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984, and later by Microsoft in Microsoft SQL Server, TDS packets can be encased in other physical transport dependent protocols, including TCP/IP, Named pipes, and Shared memory. Consequently, access to SQL Server is available over these protocols. In addition, the SQL Server API is also exposed over bando web services.

Data storage The main unit of data storage is a database, which is a collection of tables with typed columns. SQL Server supports different data types, including primary types such as Integer, Float, Decimal, Char (including character strings), Varchar (variable length character strings), binary (for unstructured blobs of data), Text (for textual data) among


others. It also allows user-defined composite types (UDT) to be defined and used. SQL Server also makes server statistics available as virtual tables and views (called Dynamic Management Views or DMV). A database can also contain other objects including views, stored procedures, indexes and constraints, in addition to tables, along with a transaction log. A SQL Server database can contain a maximum of 231 objects, and can span multiple OS-level files with a maximum file size of 220 TB. The data in the database are stored in primary data files with an extension .mdf. Secondary data files, identified with an .ndf extension, are used to store optional metadata. Log files are identified with the .ldf extension. Storage space allocated to a database is divided into sequentially numbered pages, each 8 KB in size. A page is the basic unit of I/O for SQL Server operations. A page is marked with a 96-byte header which stores metadata about the page including the page number, page type, free space on the page and the ID of the object that owns it. Page type defines the data contained in the page - data stored in the database; index, allocation map which holds information about how pages are allocated to tables and indexes, change map which holds information about the changes made to other pages since last backup or logging, or contain large data types such as image or text. While page is the basic unit of an I/O operation, space is actually managed in terms of an extent which consists of 8 pages. A database object can either span all 8 pages in an extent ("uniform extent") or share an extent with up to 7 more objects ("mixed extent"). A row in a database table cannot span more than one page, so is limited to 8 KB in size. However, if the data exceeds 8 KB and the row contains Varchar or Varbinary data, the data in those columns are moved to a new page (or possibly a sequence of pages, called an Allocation unit) and replaced with a pointer to the data. For physical storage of a table, its rows are divided into a series of partitions (numbered 1 to n). The partition size is user defined; by default all rows are in a single partition. A table is split into multiple partitions in order to spread a database over a cluster. Rows in each partition are stored in either B-tree or heap structure. If the table has an associated index to allow fast retrieval of rows, the rows are stored in-order according to their index values, with a B-tree providing the index. The data is in the leaf node of the leaves, and other


nodes storing the index values for the leaf data reachable from the respective nodes. If the index is non-clustered, the rows are not sorted according to the index keys. An indexed view has the same storage structure as an indexed table. A table without an index is stored in an unordered heap structure. Both heaps and B-trees can span multiple allocation units. Buffer management SQL Server buffers pages in RAM to minimize disc I/O. Any 8 KB page can be buffered in-memory, and the set of all pages currently buffered is called the buffer cache. The amount of memory available to SQL Server decides how many pages will be cached in memory. The buffer cache is managed by the Buffer Manager. Either reading from or writing to any page copies it to the buffer cache. Subsequent reads or writes are redirected to the in-memory copy, rather than the on-disc version. The page is updated on the disc by the Buffer Manager only if the in-memory cache has not been referenced for some time. While writing pages back to disc, asynchronous I/O is used whereby the I/O operation is done in a background thread so that other operations do not have to wait for the I/O operation to complete. Each page is written along with its checksum when it is written. When reading the page back, its checksum is computed again and matched with the stored version to ensure the page has not been damaged or tampered with in the meantime.

Logging and Transaction SQL Server ensures that any change to the data is ACID-compliant, i.e., it uses transactions to ensure that any operation either totally completes or is undone if fails, but never leaves the database in an intermediate state. Using transactions, a sequence of actions can be grouped together, with the guarantee that either all actions will succeed or none will. SQL Server implements transactions using a write-ahead log. Any changes made to any page will update the in-memory cache of the page, simultaneously all the operations performed will be written to a log, along with the transaction ID which the operation was a part of. Each log entry is identified by an increasing Log Sequence Number (LSN) which ensure that no event overwrites another. SQL Server ensures that the log will be written onto the disc before the actual page is written back. This enables SQL Server to ensure integrity of


the data, even if the system fails. If both the log and the page were written before the failure, the entire data is on persistent storage and integrity is ensured. If only the log was written (the page was either not written or not written completely), then the actions can be read from the log and repeated to restore integrity. If the log wasn't written then integrity is also maintained although the database state remains unchanged as if the transaction never occurred. If it was only partially written, then the actions associated with the unfinished transaction are discarded. Since the log was only partially written, the page is guaranteed to have not been written, again ensuring data integrity. Removing the unfinished log entries effectively undoes the transaction. SQL Server ensures consistency between the log and the data every time an instance is restarted.

Concurrency and locking SQL Server allows multiple clients to use the same database concurrently. As such, it needs to control concurrent access to shared data, to ensure data integrity - when multiple clients update the same data, or clients attempt to read data that is in the process of being changed by another client. SQL Server provides two modes of concurrency control: pessimistic concurrency and optimistic concurrency. When pessimistic concurrency control is being used, SQL Server controls concurrent access by using locks. Locks can be either shared or exclusive. Exclusive lock grants the user exclusive access to the data - no other user can access the data as long as the lock is held. Shared locks are used when some data is being read - multiple users can read from data locked with a shared lock, but not acquire an exclusive lock. The latter would have to wait for all shared locks to be released. Locks can be applied on different levels of granularity - on entire tables, pages, or even on a per-row basis on tables. For indexes, it can either be on the entire index or on index leaves. The level of granularity to be used is defined on a per-database basis by the database administrator. While a fine grained locking system allows more users to use the table or index simultaneously, it requires more resources. So it does not automatically turn into higher performing solution. SQL Server also includes two more lightweight mutual exclusion solutions - latches and spinlocks - which are less robust than locks but are less


resource intensive. SQL Server uses them for DMV and other resources that are usually not busy. SQL Server also monitors all worker threads that acquire locks to ensure that they do not end up in deadlocks - in case they do, SQL Server takes remedial measures, which in many cases is to kill one of the threads entangled in a deadlock and rollback the transaction it started. To implement locking, SQL Server contains the Lock Manager. The Lock Manager maintains an in-memory table that manages the database objects and locks, if any, on them along with other metadata about the lock. Access to any shared object is mediated by the lock manager, which either grants access to the resource or blocks it. SQL Server also provides the optimistic concurrency control mechanism, which is similar to the multi version concurrency control used in other databases. The mechanism allows a new version of a row to be created whenever the row is updated, as opposed to overwriting the row, i.e., a row is additionally identified by the ID of the transaction that created the version of the row. Both the old as well as the new versions of the row are stored and maintained, though the old versions are moved out of the database into a system database identified as Tempdb. When a row is in the process of being updated, any other requests are not blocked (unlike locking) but are executed on the older version of the row. If the other request is an update statement, it will result in two different versions of the rows both of them will be stored by the database, identified by their respective transaction IDs.

Data retrieval The main mode of retrieving data from an SQL Server database is querying for it. The query is expressed using a variant of SQL called T-SQL, a dialect Microsoft SQL Server shares with Sybase SQL Server due to its legacy. The query declaratively specifies what is to be retrieved. It is processed by the query processor, which figures out the sequence of steps that will be necessary to retrieve the requested data. The sequence of actions necessary to execute a query is called a query plan. There might be multiple ways to process the same query. For example, for a query that contains a join statement and a select statement, executing join on both the tables and then executing select on the results would give the same result as selecting from each table and then executing the join, but result in 51

different execution plans. In such case, SQL Server chooses the plan that is supposed to yield the results in the shortest possible time. This is called query optimization and is performed by the query processor itself. SQL Server includes a cost-based query optimizer which tries to optimize on the cost, in terms of the resources it will take to execute the query. Given a query, the query optimizer looks at the database schema, the database statistics and the system load at that time. It then decides which sequence to access the tables referred in the query, which sequence to execute the operations and what access method to be used to access the tables. For example, if the table has an associated index, whether the index should be used or not - if the index is on a column which is not unique for most of the columns (low "selectivity"), it might not be worthwhile to use the index to access the data, finally, it decides whether to execute the query concurrently or not. While a concurrent execution is more costly in terms of total processor time, because the execution is actually split to different processors might mean it will execute faster. Once a query plan is generated for a query, it is temporarily cached. For further invocations of the same query, the cached plan is used. Unused plans are discarded after some time. SQL Server also allows stored procedures to be defined. Stored procedures are parameterized T-SQL queries that are stored in the server itself (and not issued by the client application as is the case with general queries). Stored procedures can accept values sent by the client as input parameters, and send back results as output parameters. They can call defined functions, but not other stored procedures. They can be selectively provided access to. Unlike other queries, stored procedures have an associated name, which is used at runtime to resolve into the actual queries. Also because the code need not be sent from the client every time (as it can be accessed by name), it reduces network traffic and somewhat improves performance. Execution plans for stored procedures are also cached as necessary. SQL CLR Microsoft SQL Server 2005 includes a component named SQL CLR via which it integrates with .NET Framework. Unlike most other applications that use .NET Framework, SQL 52

Server itself hosts the .NET Framework runtime, i.e., memory, threading and resource management requirements of .NET Framework are satisfied by SQLOS itself, rather than the underlying Windows operating system. SQLOS provides deadlock detection and resolution services for .NET code as well. With SQL CLR, stored procedures and triggers can be written in any managed .NET language, including C# and VB.NET. Managed code can also be used to define UDT's (user defined types), which can persist in the database. Managed code is compiled to .NET assemblies and after being verified for type safety, registered at the database. After that, they can be invoked like any other procedure. However, only a subset of the Base Class Library is available, when running code under SQL CLR. Most APIs relating to user interface functionality are not available. When writing code for SQL CLR, data stored in SQL Server databases can be accessed using the ADO.NET APIs like any other managed application that accesses SQL Server data. However, doing that creates a new database session, different from the one in which the code is executing. To avoid this, SQL Server provides some enhancements to the ADO.NET provider that allows the connection to be redirected to the same session which already hosts the running code. Such connections are called context connections and are set by setting context connection parameter to true in the connection string. SQL Server also provides several other enhancements to the ADO.NET API, including classes to work with tabular data or a single row of data as well as classes to work with internal metadata about the data stored in the database. It also provides access to the XML features in SQL Server, including XQuery support. These enhancements are also available in T-SQL Procedures in consequence of the introduction of the new XML Datatype (query,value,nodes functions).

Services SQL Server also includes an assortment of add-on services. While these are not essential for the operation of the database system, these provide value added services on top of the core database management system. These services either run as a part of some SQL Server


component or out-of-process as Windows Service and presents their own API to control and interact with them. Service Broker The Service Broker, which runs as a part of the database engine, provides a reliable messaging and message queuing platform for SQL Server applications. Used inside an instance, it is used to provide an asynchronous programming environment. For cross instance applications, Service Broker communicates over TCP/IP and allows the different components to be synchronized together, via exchange of messages. Replication Services SQL Server Replication Services are used by SQL Server to replicate and synchronize database objects, either in entirety or a subset of the objects present, across replication agents, which might be other database servers across the network, or database caches on the client side. Replication follows a publisher/subscriber model, i.e., the changes are sent out by one database server ("publisher") and are received by others ("subscribers"). SQL Server supports three different types of replication: Transaction replication Each transaction made to the publisher database (master database) is synced out to subscribers, who update their databases with the transaction. Transactional replication synchronizes databases in near real time. Merge replication Changes made at both the publisher and subscriber databases are tracked, and periodically the changes are synchronized bi-directionally between the publisher and the subscribers. If the same data has been modified differently in both the publisher and the subscriber databases, synchronization will result in a conflict which has to be resolved - either manually or by using pre-defined policies. Snapshot replication


Snapshot replication published a copy of the entire database (the then-snapshot of the data) and replicates out to the subscribers. Further changes to the snapshot are not tracked. Analysis Services SQL Server Analysis Services adds OLAP and data mining capabilities for SQL Server databases. The OLAP engine supports MOLAP, ROLAP and HOLAP storage modes for data. Analysis Services supports the XML for Analysis standard as the underlying communication protocol. The cube data can be accessed using MDX queries. Data mining specific functionality is exposed via the DMX query language. Analysis Services includes various algorithms - Decision trees, clustering algorithm, Naive Bayes algorithm, time series analysis, sequence clustering algorithm, linear and logistic regression analysis, and neural networks - for use in data mining. Reporting Services SQL Server Reporting Services is a report generation environment for data gathered from SQL Server databases. It is administered via a web interface. Reporting services features a web services interface to support the development of custom reporting applications. Reports are created as RDL files. Reports can be designed using recent versions of Microsoft Visual Studio (including Visual Studio.NET 2003 onwards) with Business Intelligence Development Studio, installed or with the included Report Builder. Once created, RDL files can be rendered in a variety of formats including Excel, PDF, CSV, XML, TIFF (and other image formats), and HTML Web Archive. Notification Services Originally introduced as a post-release add-on for SQL Server 2000, Notification Services was bundled as part of the Microsoft SQL Server platform for the first and only time with SQL Server 2005.[ with Sql Server 2005, SQL Server Notification Services is a mechanism for generating data-driven notifications, which are sent to Notification Services subscribers. A subscriber registers for a specific event or transaction (which is registered on the


database server as a trigger); when the event occurs, Notification Services can use one of three methods to send a message to the subscriber informing about the occurrence of the event. These methods include SMTP, SOAP, or by writing to a file in the file system. Integration Services SQL Server Integration Services is used to integrate data from different data sources. It is used for the ETL capabilities for SQL Server for data warehousing needs. Integration Services includes GUI tools to build data extraction workflows integration various functionality such as extracting data from various sources, querying data, transforming data including aggregating, duplication and merging data, and then loading the transformed data onto other sources, or sending e-mails detailing the status of the operation.

Full Text Search Service SQL Server Full Text Search service is a specialized indexing and querying service for unstructured text stored in SQL Server databases. The full text search index can be created on any column with character based text data. It allows for words to be searched for in the text columns. While it can be performed with the SQL LIKE operator, using SQL Server Full Text Search service can be more efficient. Full Text Search (FTS) allows for inexact matching of the source string, indicated by a Rank value which can range from 0 to 1000 a higher rank means a more accurate match. It also allows linguistic matching ("inflectional search"), i.e., linguistic variants of a word (such as a verb in a different tense) will also be a match for a given word (but with a lower rank than an exact match). Proximity searches are also supported, i.e., if the words searched for do not occur in the sequence they are specified in the query but are near each other, they are also considered a match. T-SQL exposes special operators that can be used to access the FTS capabilities. The Full Text Search engine is divided into two processes - the Filter Daemon process (msftefd.exe) and the Search process (msftesql.exe). These processes interact with the SQL Server. The Search process includes the indexer (that creates the full text indexes) and the full text query processor. The indexer scans through text columns in the database. It can 56

also index through binary columns, and use iFilters to extract meaningful text from the binary blob (for example, when a Microsoft Word document is stored as an unstructured binary file in a database). The iFilters are hosted by the Filter Daemon process. Once the text is extracted, the Filter Daemon process breaks it up into a sequence of words and hands it over to the indexer. The indexer filters out noise words, i.e., words like A, And etc, which occur frequently and are not useful for search. With the remaining words, an inverted index is created, associating each word with the columns they were found in. SQL Server itself includes a Gatherer component that monitors changes to tables and invokes the indexer in case of updates. When a full text query is received by the SQL Server query processor, it is handed over to the FTS query processor in the Search process. The FTS query processor breaks up the query into the constituent words, filters out the noise words, and uses an inbuilt thesaurus to find out the linguistic variants for each word. The words are then queried against the inverted index and a rank of their accurateness is computed. The results are returned to the client via the SQL Server process. Tools SQLCMD SQLCMD is a command line application that comes with Microsoft SQL Server, and exposes the management features of SQL Server. It allows SQL queries to be written and executed from the command prompt. It can also act as a scripting language to create and run a set of SQL statements as a script. Such scripts are stored as a .sql file, and are used either for management of databases or to create the database schema during the deployment of a database. SQLCMD was introduced with SQL Server 2005 and this continues with SQL Server 2008. Its predecessor for earlier versions was OSQL, which is functionally equivalent and many of the command line parameters are identical.


Visual Studio Microsoft Visual Studio includes native support for data programming with Microsoft SQL Server. It can be used to write and debug code to be executed by SQL CLR. It also includes a data designer that can be used to graphically create, view or edit database schemas. Queries can be created either visually or using code. SSMS 2008 onwards, provides intellisense for SQL queries as well. SQL Server Management Studio SQL Server Management Studio is a GUI tool included with SQL Server 2005 and later for configuring, managing, and administering all components within Microsoft SQL Server. The tool includes both script editors and graphical tools that work with objects and features of the server. SQL Server Management Studio replaces Enterprise Manager as the primary management interface for Microsoft SQL Server since SQL Server 2005. A version of SQL Server Management Studio is also available for SQL Server Express Edition, for which it is known as SQL Server Management Studio Express (SSMSE). A central feature of SQL Server Management Studio is the Object Explorer, which allows the user to browse, select, and act upon any of the objects within the server. It can be used to visually observe and analyze query plans and optimize the database performance, among others. SQL Server Management Studio can also be used to create a new database, alter any existing database schema by adding or modifying tables and indexes, or analyze performance. It includes the query windows which provide a GUI based interface to write and execute queries. Business Intelligence Development Studio Business Intelligence Development Studio (BIDS) is the IDE from Microsoft used for developing data analysis and Business Intelligence solutions utilizing the Microsoft SQL Server Analysis Services, Reporting Services and Integration Services. It is based on the Microsoft Visual Studio development environment but customizes with the SQL Server services-specific extensions and project types, including tools, controls and projects for reports (using Reporting Services), Cubes and data mining structures (using Analysis Services).


Programmability T-SQL T-SQL (Transact-SQL) is the primary means of programming and managing SQL Server. It exposes keywords for the operations that can be performed on SQL Server, including creating and altering database schemas, entering and editing data in the database as well as monitoring and managing the server itself. Client applications, both which consume data or manage the server, leverage SQL Server functionality by sending T-SQL queries and statements which are then processed by the server and results (or errors) returned to the client application. SQL Server allows it to be managed using T-SQL. For this it exposes read only tables from which server statistics can be read. Management functionality is exposed via system-defined stored procedures which can be invoked from T-SQL queries to perform the management operation.

SQL Native Client SQL Native Client is the native client side data access library for Microsoft SQL Server, version 2005 onwards. It natively implements support for the SQL Server features including the Tabular Data Stream implementation, support for mirrored SQL Server databases, full support for all data types supported by SQL Server, asynchronous operations, query notifications, encryption support, as well as receiving multiple result sets in a single database session. SQL Native Client is used under the hood by SQL Server plug-ins for other data access technologies, including ADO or OLE DB. It is also used by the native SQL Server ADO.NET provider, SqlClient. The SQL Native Client can also be directly used, bypassing the generic data access layers. Features:

High Availability - Failover clustering and database mirroring technology in SQL Server 2005 will enable enterprises to deliver highly reliable, available applications to employees, customers, and partners. 59

Management Tools - SQL Server 2005 introduces an integrated suite of management tools and management application programming interfaces (APIs) to provide ease of use, manageability, and support for operating large-scale SQL Server deployments. Security Enhancements - SQL Server 2005 has been designed to help provide the highest level of security for enterprise data through features such as database encryption, more secure default settings, password policy enforcement, granular permissions control, and an enhanced security model. Scalability - Scalability advancements in SQL Server 2005 include table partitioning, replication enhancements, and 64-bit support. Fast Recovery - A new faster recovery option improves availability of SQL Server databases. Administrators can reconnect to a recovering database after the transaction log has been rolled forward.

3.2 Testing Software testing is a process of running with intent of finding errors in software. Software testing assures the quality of software and represents final review of other phases of software like specification, design, code generation etc.

3.2.1 Unit Testing Unit testing emphasizes the verification effort on the smallest unit of software design i.e.; a software component or module. Unit testing is a dynamic method for verification, where program is actually compiled and executed. Unit testing is performed in parallel with the coding phase. Unit testing tests units or modules not the whole software. I have tested each view/module of the application individually. As the modules were built up testing was carried out simultaneously, tracking out each and every kind of input and checking the corresponding output until module is working correctly. The functionality of


the modules was also tested as separate units. Each of the three modules was tested as separate units. In each module all the functionalities were tested in isolation. In the Shop Products Module when a product has been added to cart it has been made sure that if the item already exists in the shopping cart then the quantity is increased by one else a new item is created in the shopping cart. Also the state of the system after a product has been dragged in to the shopping cart is same as the state of the system if it was added by clicking the add to cart button. Also it has been ensured that all the images of the products displayed in the shop products page are drag gable and have the product Poperty so that they can be dropped in the cart area. In the Product Description Module it has been tested that all the images aredisplayed properly. Users can add review and the as soon as a user adds a review it is updated in the view customer review tab. It has been checked to see if the whole page refreshes or a partial page update happens when a user writes a review. In the Cart Details it has been tested that when a user edits a quantity or removes a product from the cart, the total price is updated accordingly. It has been checked to see if the whole page refreshes or a partial page update happens when a user edits the cart. Visual Studio 2008 has in built support for testing the application. The unit testing can be done using visual studio 2008 without the need of any external application. Various methods have been created for the purpose of unit testing. Test cases are automatically generated for these methods. The tests run under the ASP.NET context which means settings from Web.config file are automatically picked up once the test case starts running. Methods were written to retrieve all the manufacturers from the database, strings that match a certain search term, products that match certain filter criteria, all images that belong to a particular product etc. Unit test cases were automatically generated for these methods and it can be seen in figure 6.1 that the tests have passed. 3.2.2 Integration Testing In integration testing a system consisting of different modules is tested for problems arising from component interaction. Integration testing should be developed from the system specification. Firstly, a minimum configuration must be integrated and tested. In my project I have done integration testing in a bottom up fashion i.e. in this project I have started construction and testing with atomic modules. After unit testing the modules are


integrated one by one and then tested the system for problems arising from component interaction. 3.2.3 Validation Testing It provides final assurances that software meets all functional, behavioral & performance requirement. Black box testing techniques are used. There are three main components Validation test criteria (no. in place of no. & char in place of char) - Configuration review (to ensure the completeness of s/w configuration.) - Alpha & Beta testing-Alpha testing is done at developer’s site i.e. at home & Beta testing once it is deployed. Since I have not deployed my application, I could not do the Beta testing. Test Cases- I have used a number of test cases for testing the product. There were different cases for which different inputs were used to check whether desired output is produced or not. 1. Addition of a new product to the cart should create a new row in the shopping cart. 2. Addition of an existing product to the cart has to update the quantity of the product. 3. Any changes to items in the cart have to update the summary correctly. 4. Because same page is inserting data into more than one table in the database atomicity of the transaction is tested. 5. The state of the system after a product has been dragged in to the cart should be ame as the state of the system if the same product is added to the cart by clicking button.

3.2.4 White Box Testing In white box testing knowing the internal working of the product, tests can be conducted to ensure that internal operations are performed according to specification and will internal components have been adequately exercised. In white box testing logical path through the software are tested by providing test cases that exercise specific sets of Conditions and loops. Using white-box testing software developer can derive test case that


• Guarantee that all independent paths within a module have been exercised at least once. • Exercise all logical decisions on their true and false side. • Exercise all loops at their boundaries and within their operational bound. • Exercise internal data structure to ensure their validity. At every stage of project development I have tested the logics of the program by supplying the invalid inputs and generating the respective error messages. All the loops and conditional statements are tested to the boundary conditions and validated properly. 3.2.4 Performance Testing Jakarta JMeter, a tool for testing applications was used to simulate the virtual users (clients) and test the performance of the system. It can be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. It can be used to make a graphical analysis of performance and test the server/script/object behavior under heavy concurrent load. I have done performance testing to achieve an estimate of the peak and sustained load the application. This has done with few pages like the Shop Products (extensive Database access, business logic Intensive and more Images) and the Cart Details (simple page). A few sample Screenshots of test results are shown below. The tests have been conducted by running the application (server) and JMeter on same machine. These test results do not include factors like network bandwidth etc as the server is running on the same machine along with JMeter.


CHAPTER 4 Summary, Conclusion and Suggestion

4.1 Results & Challenges The application can be used for any Ecommerce application. It is easy to use, since it uses the GUI provided in the user dialog. User friendly screens are provided. The application is easy to use and interactive making online shopping a recreational activity for users. It has been thoroughly tested and implemented. 4.1.1 Challenges • Compatibility with browsers like Mozilla Firefox, Internet explorer etc


• •

Using a layered approach in developing the application which would make the application maintainable. Learning new technologies like using JavaScript for drag and drop behavior and Ajax toolkit controls with little guidance. The overall idea of doing this project is to get a real time experience. Learn new technologies.

4.2 Conclusions The ‘Online Shopping’ is designed to provide a web based application that would make searching, viewing and selection of a product easier. The search engine provides an easy and convenient way to search for products where a user can Search for a product interactively and the search engine would refine the products available based on the user’s input. The user can then view the complete specification of each product. They can also view the product reviews and also write their own reviews. Use of Ajax components would make the application interactive and prevents annoying post backs. Its drag and drop feature would make it easy to use.

4.3 Limitations
This application does not have a built in check out process. An external checkout package has to be integrated in to this application. Also users cannot save the shopping carts so that they can access later i.e. they cannot create wish lists which they can access later. This application does not have features by which user can set price ranges for products and receive alerts once the price reaches the particular range.

4.4 Scope for Future Work
The following things can be done in future. • • • The current system can be extended to allow the users to create accounts and save products in to wish list. The users could subscribe for price alerts which would enable them to receive messages when price for products fall below a particular level. The current system is confined only to the shopping cart process. It can be extended to have an easy to use check out process.


Users can have multiple shipping and billing information saved. During checkout they can use the drag and drop feature to select shipping and billing information.

4.5 References • • • • • • • All about Microsoft controls in C# Wikipedia for various diagrams & testing methods Cool text for Images and Buttons K-State Research Exchange for samples in report writing Smart Draw for drawing all the Diagrams used in this report. Sample Ecommerce Application Ajax Toolkit controls