Archive

Archive for December, 2013

Developing & Testing a program in Java

December 28, 2013 Leave a comment

 

 

Module 3: Developing & Testing a Java Technology program.

 

Objectives:

1. Identify  4 components of class.
2. Use main method in a test class to run a java program from command line.
3. Compile & execute a java program.

 

1. Identify  4 components of class:

Going back to what we discussed before about classes, to construct a house you will first need a blueprint. Same thing applies for classes & objects. Similarly once you have a class blueprint, you  can have as many objects of that class as u like. These objects are called instances of a class. i.e., a shirt object is an instance of a shirt class.

 

27. class and its objs

 

Lets take a look at our first class:

Class is a blueprint that tells the computer how to make objects. This class blueprint – Shirt, tells the computer how to make Shirt objects.

 

28. 1st class

 

 

Structuring classes:

There are 4 major components of class that you will find more often:

  • class declaration – required
  • attribute variable declaration & initialization – optional
  • methods – optional
  • comments – optional

1. Class declaration is required, and this is all that you need to make a class valid. If all you had was this, then the class and its objects would be uninteresting serving no purpose. You will be needing some attributes and operations to jazz up the object.

2. Variables are characterstics of your objects. As we discussed in previous posts, these are characterstics /  properties and they are also data holders. They hold the data for the object.

3. In this Shirt class, only one method is defined. Methods are operations. They tell the class what to do.  Its what the class can do.  This method is printing all its information to the command window.

4. Comments are for developers to understand what the code is doing, they dont influence the execution in anyway.

 

Class declaration: Read more…

Advertisements

Analyze a problem & design a solution in Java

December 25, 2013 7 comments

  

Module 2 – Analyze a problem & design a solution.

 

Objective:

Analyzing a problem & designing a solution using object oriented concepts:

1. Analyse a problem using object oriented analysis
2. Design classes from which objects will be created

 

1. Analyze a problem using object oriented analysis:

In this process, the first step is to understand your domain & the domain will probably be the business you are trying to solve the pblm for, or the area to create new product.

 Case study:

A company called Direct Clothing  sells shirts from thier catalog.  We have to develop a product for this company for the same catalog. So initially we have to understand few points about thier shirts
ex:

  • Each shirt has an item identity(ID) – bar code
  • One or more colors – blue, green etc
  • One or more sizes
  • Have description – type of material, style etc
  • Price
  • Direct Clothing accepts cheques & credit card payments.

 

11. case study

 

 

The current system:

During analysis stage, you also have to learn about the current system if there is one. Currently, say there are 2 ways in which a customer can place thier order with Direct Clothing

  • Call customer care over phone and place the order.
  • Mail or Fax an order form to place the order.

 

12. current system

 

The proposed system: Read more…

Explaining Java Technology

December 20, 2013 Leave a comment

  

Module 1 – Explaining Java Technology.

 

Objective:

Upon completion of reading this post, you should be able to know:

  • Key concepts of Java programming language.
  • Three Java technology product groups.
  • Seven stages of product life cycle.

 

 

Key concepts of Java programming language:

Java programming language originated in Sun Microsystems in 1999 as part of a research project to develop a programming language calld oak that would bridge the communication gap between many consumer devices such as video casette recorders & TV. Specifically, a team called green team wanted to create a software programming language enabling consumer devices with different CPU to share same software enhnacements.

 

 

1. green team

 

Initial concept failed as several deals with consumer companies were unsuccessful. So green team had to find another market. At that time www was becoming popular, and green team recognized tht the Oak language was perfect for developing web multimedia components to enhance web pages. Initially, small programs called applets became extensively used and gradually internet developers adopted what now is known as Java.

2. green team with internet

 

 

Java was designed to be: Read more…

Transactions & MySQL

December 15, 2013 Leave a comment

 

 

MySQL supports small, embedded kiosk-style applications as well as the occasional five billion-record data warehouse. This versatility is possible in part because of the MySQL engine, which has been designed for maximum scalability, maximum resource efficiency, and easy portability to various platforms and architectures. This section will discuss the important characteristics of this engine in detail.

 

Connectivity:

MySQL is designed on the assumption that the vast majority of its applications will be running on a TCP/IP (Transmission Control Protocol/Internet Protocol) network. This is a fairly good assumption, given that TCP/IP is not only highly robust and secure, but is also common to UNIX, Windows, OS/2, and almost any other serious operating system you’ll likely encounter.

MySQL does allow named-pipe connections, which were designed mainly to support network connections in earlier non-TCP/IP networks, such as LAN Manager and Windows NETBEUI. (NETBEUI uses an addressing scheme based on the NETBIOS machine name rather than a routable IP address.)

 

SQL:

The Structured Query Language (SQL) is an open standard that has been maintained by the American National Standards Institute (ANSI) since 1986. Although it’s true that the implementation of this standard does differ in varying degrees from vendor to vendor, it’s fair to say that SQL is today one of the most widely used cross-vendor languages. As with other implementations, such as SQL Server’s T-SQL (Transact-SQL) and Oracle’s SQL, MySQL has its own variations of the SQL standard that add power beyond what is available within the standard.

 

Data Integrity:

MySQL supports engine-level data integrity through the use of primary key and foreign key constraints. Columns can be defined so that explicit NULL values cannot be entered into them. To prevent empty columns, MySQL supports the use of default values, which, when combined with NOT NULL properties, ensure that valid data is entered into a column that would otherwise be left blank.

 

Transactions:

Until recently, MySQL was not known for its transaction-handling capabilities; however, since version 3.23, MySQL has been providing table handlers, such as InnoDB and BDB, that manage transactions in much the same manner as other commercial RDBMS products. A transaction-safe database system must pass what is known as the ACID test to qualify for compliance. An ACID-compliant database must support the following characteristics:

  • Atomicity
  • Consistency
  • Isolation
  • Durability

 

Atomicity:

A transaction is defined as an action, or a series of actions, that can access or change the contents of a database. In SQL terminology, a transaction occurs when one or more SQL statements operate as one unit. Each SQL statement in such a unit is dependent on the others; in other words, if one statement does not complete, the entire unit will be rolled back, and all the affected data will be returned to the state it was in before the transaction was started. Grouping the SQL statements as part of a single unit (or transaction) tells MySQL that the entire unit should be executed atomically.

Atomic execution is an all-or-nothing proposition. All of the SQL statements must be completed for the database to maintain a state of data integrity; otherwise, none of the statements will be finalized and committed to disk. In MySQL, the beginning of a transaction is marked with a BEGIN statement. The transaction (or unit of work) will not be considered complete until a COMMIT command is issued to tell MySQL to complete the action. When necessary, the ROLLBACK command will initiate a rolling back of all changes to the state before the BEGIN statement.

An everyday real-world example of this can be found in the banking business. By debiting and crediting your bank account, your bank adds and subtracts money from the account within one transaction. These updates usually involve multiple tables. The bank would not be able to maintain data integrity without guaranteeing that the entire transaction will take place, not just part of it.

Transaction management is particularly important to client-server systems that perform data entry or to any application that must be able to count on a high degree of safety from undetected data loss, such as the banking example described here.

 

Consistency:

Consistency exists when every transaction leaves the system in a consistent state, regardless of whether the transaction completes successfully or fails midway.

For example, imagine that your bank uses a transaction that is supposed to transfer money from one bank account to another. If the transaction debits one bank account for the requisite amount but fails to credit the other account with a corresponding amount, the system would no longer be in a consistent state. In this case, the transaction would violate the consistency constraint, and the system would no longer be ACID-compliant.

In MySQL, consistency is primarily handled by MySQL’s logging mechanisms, which record all changes to the database and provide an audit trail for transaction recovery. If the system goes down in the middle of a transaction, the MySQL recovery process will use these logs to discover whether or not the transaction was successfully completed and roll it back if required.

In addition to the logging process, MySQL also provides locking mechanisms that ensure that all of the tables, rows, and indexes that make up the transaction are locked by the initiating process long enough to either commit the transaction or roll it back.

 

Isolation:

Isolation implies that every transaction occurs in its own space, isolated from other transactions that may be occurring in the system, and that the results of a transaction are visible only once the entire sequence of events making up the transaction has been fully executed. Even though multiple transactions may be occurring simultaneously in such a system, the isolation principle ensures that the effects of a particular transaction are not visible until the transaction is fully complete.

This is particularly important when the system supports multiple simultaneous users and connections (as MySQL does); systems that do not conform to this fundamental principle can cause massive data corruption, as the integrity of each transaction’s individual space will be quickly violated by other competing, often conflicting, transactions.

Interestingly, MySQL offers the use of server-side semaphore variables that act as traffic managers to help programs manage their own isolation mechanisms. These variables are useful in cases for which you prefer not to incur the overhead of the Transaction Managers, or when a recovery plan is possible outside of the confines of log recovery. MySQL InnoDB tables offer isolation in transactions involving multiple queries, while MyISAM tables allow you to simulate isolation via the LOCK TABLES command.

 

Durability:

Durability, which means that changes from a committed transaction persist even if the system crashes, comes into play when a transaction has completed and the logs have been updated in the database. Most RDBMS products ensure data consistency by keeping a log of all activity that alters data in the database in any way. This database log keeps track of any and all updates made to tables, queries, reports, and so on. If you have turned on the database log , you already know that using it will slow down the performance of your database when it comes to writing data. (It will not, however, affect the speed of your queries.)

In MySQL, you can specify whether or not you wish to use transactions by choosing the appropriate table handlers, depending on your application. The InnoDB table handler performs logging a bit differently than BDB does, while MyISAM does not support the type of logs that would permit you to be assured of a durable database. By default, InnoDB tables are 100% durable to the last second prior to a crash. MyISAM tables offer partial durability—all changes committed to the system prior to the last FLUSH TABLES command are guaranteed to be saved to disk.

SQL Server and Oracle, for instance, are able to restore a database to a previous state by restoring a previously backed-up database and, in essence, “replaying” all subsequent transactions up until the point of failure. These database products do not encourage the direct use of—nor do they expose the inner data structures of—the log files, because those files form part of the database engine’s recovery mechanism.

MySQL also keeps a binary log of all data manipulation activity in sequential order. However, unlike the logs used in other databases, this log is easy to read, which means that it’s a relatively straightforward task to recover lost data by using the last backup in combination with the log.

 

Links:

http://www.mysql.com/

 

Note: Refer to other MySQL related posts for further knowledge.

 

Advanced Concepts:

Introduction:

Videos / Technology Talks:

What & Why?:

Installations & Configurations:

 

Tomcat Primer

December 7, 2013 1 comment

 

  

Tomcat Logo

 

 

 

Apache Origin:

Apache Tomcat (or Jakarta Tomcat or just Tomcat) is an open source servlet container started out as a reference implementation by Sun Microsystems and donated to the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Sun Microsystems, and provides a “pure Java” HTTP web server environment for Java code to run. Tomcat should not be confused with the Apache web server, which is a C implementation of an HTTP web server; these two web servers are not bundled together. Apache Tomcat includes tools for configuration and management, but can also be configured by editing XML configuration files.

Members of the ASF and independent volunteers develop and maintain Tomcat. Users have free access to the source code and to the binary form of Tomcat under the Apache License and hence is freely downloadable. The initial Tomcat release appeared with versions 3.0.x. Tomcat 6.0.20 is the latest production quality release of the 6.0.x trunk (based on 2.5 servlet specification).

Tomcat started off as a servlet reference implementation by James Duncan Davidson, a software architect at Sun Microsystems. He later helped make the project open source and played a key role in its donation by Sun to the Apache Software Foundation.

 

Tomcat Introduction:

Tomcat is a Java Servlet/JSP container and web server from the Jakarta project of the Apache software foundation. A web server dishes out web pages in response to requests from a user which typically is a web browser. But web servers are not limited to serving up static HTML pages; they can also run programs in response to user requests and return the dynamic results to the user’s browser. Tomcat is very good at this because it provides both Java servlet and JavaServerPages (JSP) technologies (in addition to traditional static pages and external CGI programming). Tomcat can be used as either a standalone product with its own internal Web server or together with other Web servers, including Apache, Netscape Enterprise Server, Microsoft Internet Information Server (IIS), and Microsoft Personal Web Server where the traditional server can be used to serve static pages and Tomcat can be used to serve dynamic servlet and JSP requests.

Tomcat is one of several open source collaborations called Jakarta. Tomcat requires a Java Runtime Enterprise Environment that conforms to JRE 1.1 or later. Developed under the Apache license in an open and participatory environment, Tomcat is intended to be a collaboration of the best-of-breed developers from around the world.

 

Some of the Tomcat and related definitions:

Apache:
“The Apache software foundation provides support for the Apache community of open-source software projects. The Apache projects are characterized by a collaborative, consensus based development process, an open and pragmatic software license, and a desire to create high quality software that leads the way in its field.” Amongst the projects that come under the “Apache” banner are the HTTP Web Server from which the whole Apache project has grown, and which is the container used for the majority of web sites worldwide, Ant (a build tool which allows the developer excellent control of the compiling and bundling processes), and Jakarta.

Jakarta:
“The Jakarta Project creates and maintains open source solutions on the Java platform for distribution to the public at no charge. Jakarta products are developed by and distributed through various sub-projects.” Jakarta is the name for the Apache project which deals with the provision of open source additions in Java. More than 20 such additions (known as sub-projects) are listed on their web site, including Struts and Tomcat.

Tomcat:
Tomcat is a servlet container for the Java Servlets and JavaServer Pages. It provides a Java Virtual Machine and associated elements to give a complete Java Runtime Environment, and it also provides web server software to make that environment accessible on the Web. Configuration and management tools are also provided, with configuration data largely held in XML. It’s worth noting that Tomcat is much more than just an implementation of Servlets and JSPs, it’s the official reference implementation and the standard against which all other suppliers of containers for Servlets and JSPs must measure their products. It means that developers know that if they develop code that works under Tomcat, that code should work under other containers that conform to the standards set.

 

 

Tomcat Architecture: Read more…

Why Tomcat?

December 3, 2013 Leave a comment

 

 

Why Webserver?

Have you ever wondered about the mechanisms that delivered this page to you? So, when you clicked on the link for this page, or typed its URL (Uniform Resource Locator), what happened behind the scenes to bring this page onto your screen? If you’ve ever been curious about the process, or have ever wanted to know some of the specific mechanisms that allow you to surf the Internet, then read on. At the most basic level possible, the following diagram shows the steps that brought that page to your screen:

 

 

 

webserver-basic

 

 

The browser breaks the URL into three parts:

  • The protocol (“http”)
  • The server name (“www.tecneosis.com“)
  • The file name (“why-tomcat.htm”)

The browser communicates with a name server to translate the server name “www.tecnoesis.com” into an IP Address, which then the browser uses to connect to the server machine. The browser then forms a connection to the server at that IP address on port 80. Following the HTTP protocol, the browser sends a GET request to the server, asking for the file “http://www.tecnoesis.com/why-tomcat.htm.” The server then sends the HTML text for the Web page to the browser. The browser reads the HTML tags and formats the page onto your screen. Your browser forms a connection to a Web server, requests a page and receives it.

 

Clients and Servers:

In general, all of the machines on the Internet can be categorized as two types: servers and clients. Those machines that provide services (like Web servers or FTP servers) to other machines are servers. And the machines that are used to connect to those services are clients. When you connect to Yahoo! at www.yahoo.com to read a page, Yahoo! is providing a machine (probably a cluster of very large machines),to service your request. Yahoo! then is a server. Your machine, on the other hand, is a user machine also known as a client.

The server usually serves either static or dynamic pages to the client. Static pages are those that do not change unless the creator of the page edits it. Dynamic pages are those which the server has to perform certain processes (invoke the component that executes perticular logic) to dynamically display the content to the client.

 

Tomcat as a Webserver: Read more…