28 September 2009
0 SQL Tutorial - Find and Replace Text in MySQL Database
SQL Tutorial - Tips2- Find and Replace Text in MySQL
How to Find and Replace Text in MySQL Database using SQL Statements?
The syntax of REPLACE is REPLACE(text_string, from_string, to_string)
For example:
0 SQL Tutorial -" NULL in SQL"
SQL Tutorial - Tips1- 'NULL in SQL'
The Four Golden Rules for 'NULL' in SQL
1. Use NULLs to indicate unknown/missing information only. Do not use NULLs in place of zeroes, zero-length strings or other "known: blank values. Update your NULLs with proper information as soon as possible.
2. In ANSI SQL, NULL is not equal to anything, even other NULLs! Comparisons with NULL always result in UNKNOWN
3. Use SET ANSI_NULLS ON, and always use ANSI standard SQL syntax for NULLs. Straying from the standard can cause problems including portability issues, incompatibility with existing code and databases and returning incorrect results.
4. The ANSI standard COALESCE() and CASE syntaxes are preferred over ISNULL() or other proprietary syntax
No Two NULLs Are Created Equal
ANSI SQL three-valued logic (3VL) is that NULL is not equal to anything else. It is not less than, greater than, or even unequal to anything else either.
All NULLs Are Created Not Distinct
From above we know that comparisons with NULL never evaluate to TRUE or FALSE, that NULL is never equal to NULL, and that NULL comparisons always result in UNKNOWN. Now it's time to list the exceptions. In order to simulate NULL equality, and to keep from contradicting themselves in the process, the ANSI SQL-92 standard decreed that two NULL values should be considered "not distinct". The definition of not distinct in the ANSI standard includes any two values that return TRUE for an equality test (e.g., 3 = 3, 4 = 4, etc.), or any two NULLs. This simulated NULL equality is probably most used in the GROUP BY clause, which groups all NULL values into a single partition. In Unique Constraint also NULLs are treated same.
NULLs Flock Together
The ORDER BY clause in SELECT queries places all NULL values together when it orders your results. SQL Server treats NULLs as the "lowest possible values" in your results. What this means is NULL will always come before your non-NULL results when you sort in ascending order, and after your non-NULL results when you sort in descending order
23 September 2009
13 September 2009
0 Basic JAVA Tutorial - JAVA Installation and Set Up Guide
Basic JAVA Tutorial - CHAPTER-8 installation and Set Up of JAVA
Installing and using JAVA
Before we begin JAVA installation, some points on JAVA installation
• For executing Java Programs Java 2 SDK Version 1.4 or higher Version needs to be installed.
• Java 2 SDK Can be downloaded freely from http://java.sun.com
• IDEs for JAVA are Eclipse and Netbeans, and Eclipse can be downloaded freely and doesnot require installation
Setting Environment variables for Java
We need to set some Environmental variables.
• Environmental variable is a variable that describes the operating environment of the process
• Common environment variables describe the home directory, command search path etc.
Environment variables used by JVM
JAVA_HOME
This environment variable is pointing to the Java Installation directory. This environment variable is used to derive all other environment variables used by JVM
set JAVA_HOME=C:\ProgramFiles\JAVA\jdk1.4.3
In UNIX:
export JAVA_HOME=/var/usr/java
CLASSPATH
Path variable is used by OS to locate executable files
set PATH=%PATH%;%JAVA_HOME%\lib\tools.jar
In UNIX:
set PATH=$PATH:$JAVA_HOME/lib/tools.jar:.
Do the Environmental variable settings by typing the given commands in the Command Prompt and Type ‘javac’. It will display all the options of using javac as shown in the diagram. If it says bad command or file name then check the path setting.
Alternate way to set CLASSPATH
set PATH=%PATH%;%JAVA_HOME%\bin
In UNIX:
set PATH=$PATH:$JAVA_HOME/bin
0 Basic JAVA Tutorial - JAVA Architecture
Basic JAVA Tutorial - CHAPTER-6 Architecture of JVM Runtime Environment
JAVA Platform Architecture
The JVM Runtime Environment
The byte codes are stored in class files. At runtime, the bytecodes that make up a java software program are loaded, checked, and run in an interpreter. The interpreter has two functions: it executes bytecodes, and makes the appropriate calls to the underlying hardware.
The Java runtime environment runs code compiled for a JVM and performs four main tasks:
• Loads Code - Performed by the class loader
• Verifies Code - Performed by the bytecode verifier
• Executes Code - Performed by the runtime interpreter
• Garbage Collection - De allocates memory not being used
Class Loader
The class loader loads all classes needed for the execution of a program. The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.
Once all the classes have been loaded, the memory layout of the executable file is determined. At this point specific memory addresses are assigned to symbolic references and the lookup table is created. Because memory layout occurs at runtime, the java technology interpreter adds protection against unauthorized access into the restricted areas of code.
Java software code passes several tests before actually running on your machine. The JVM puts the code through a bytecode verifier that tests the format of code fragments and checks code fragments for illegal code ie code that forges pointers, violates access rights on objects, or attempts to change object type.
The bytecode verifier makes four passes on the code in a program. It ensures that the code follows the JVM specifications and does not violate system integrity. If the verifier completes all four passes without returning an error message, then the following is ensured. The classes follow the class file format of the JVM specification
• There are no access restriction violations
• The code causes no operand stack overflows or underflows
• No illegal data conversions
0 Basic JAVA Tutorial - JAVA Architecture
Basic JAVA Tutorial - CHAPTER-7 Architecture of JVM Runtime Environment
JAVA Platform Architecture Continues..
Garbage Collection
As the objects are dynamically allocated memory by using "new" operator, they must be released for later reallocation. Java handles de-allocation automatically. This technique is called Garbage Collection.
When no references to an object exist, that object is assumed to be no longer needed and the memory occupied by the object can be reclaimed. This is done by Garbage Collection. Garbage Collection occurs periodically during the execution of the program.
Finalize
Finalize method is used when certain objects are required to perform some action when they are destroyed. By using this method, we can define specific actions that will occur when an object is just about to be reclaimed by the garbage collector.
When certain objects are required to perform some action when they are destroyed then those actions can be added by defining finalize() method. Java Run time calls that method whenever it is about to recycle an object of that class.
The Garbage collector runs periodically, checking for objects that are no longer referenced by any running state or indirectly through other referenced objects. Right before an object is freed, the Java Run time calls the finalize() method on that object.
0 Basic JAVA Tutorial - Platform Independence of JAVA
Basic JAVA Tutorial - CHAPTER-5 Platform Independence of JAVA and JVM
JAVA is Platform Independent
Java is a language that is platform independent.
• A platform is the hardware and software environment in which a program runs
• Once compiled, code will run on any platform without recompiling or any kind of modification.
– “Write Once Run Anywhere”
• JAVA Program Portability is made possible by making use of a Java Virtual Machine commonly known as JVM
Always keep onething in mind, only the programs written in JAVA language is portable, JVM or Java platform is not portable. These JAVA platforms are purely platform dependent, it will depend on the underlying Operating system and defenitely hardware also. That is, Windows OS has its own JVM, or JRE, and so as Mac, UNIX, LINUX etc
Java Virtual Machine (JVM)
The source code of Java will be stored in a text file with extension .java
• The Java compiler compiles a .java file into byte code
• The byte code will be in a file with extension .class
• The .class file that is generated is the machine code of the processor.
– Byte code is a binary language
• The byte code is interpreted by the JVM
• JVM varies from platform to platform, or, JVM is platform dependent
• JVM can be considered as a processor purely implemented with software.
• The interface that the JVM has to the .class file remains the same irrespective of the underlying platform.
– This makes platform independence possible
• The JVM interprets the .class file to the machine language of the underlying platform.
• The underlying platform processes the commands given by the JVM
0 Basic JAVA Tutorial - Features of JAVA
Basic JAVA Tutorial - CHAPTER-4
Features of JAVA - Object Oriented
Java is an Object Oriented Language. Object-Oriented design is a technique that helps the programmer visualize the program using real-life objects.
Eventhough JAVA is an Object Oriented language, Unlike C++, It will not support Operator Overloading and Multiple inheritance. But, like every other Object oriented languages JAVA will support method overloading.
Features of JAVA - Robust
JAVA programming language is built in such a way that programmers can easily write Robust Programs.
For any programming language, the main reasons for program failure are:
(1) Memory management mistakes
(2) Mishandled run time errors.
Java has solution to both these problems.
(1) With Java, Memory management is very easy since the de allocation is done by the garbage collector automatically.
(2) Java provides object oriented exception handling to manage run time errors.
Features of JAVA - Platform independent
Java is platform independent or in other words JAVA is Architecture Neutral or simply Portable. About a JAVA program, we can say "Write once, Run anywhere". Java is an Interpreter based language. With Java, the program needs to be compiled only once, and the code generated by the Java compiler can run on any platform. Java is platform independent at both the source and the binary level. Java can be easily ported on any type of system and irrespective of the operating system being used. Java achieves this portability due to its feature of Implementation Independency.
Features of JAVA - Secured
Java is a secured programming language because it provides the user with a Virtual Firewall between the applications and the computer thus ensuring that the data in the user’s system is protected by any possible Infectious contents. This is achieved by confining the Java program within the Java Runtime Environment.
Features of JAVA - Multithreading
Multithreading is the capability for a program to perform several tasks simultaneously within a program. A good example of mutithreading would be one of the game software where the GUI display, sound effect, timer control and score updating are happening within the same process simultaneously. In network programming, a server can serve multiple clients at the same time via mutithreading.
Features of JAVA - Designed for the Distributed Environment
Java is designed for the distributed environment of the Internet. Simply speaking, Java allows objects on two different computers to execute procedures remotely.
Features of JAVA - Simple
Java is a Simpler Language comparing to other Object oriented languages like C++. The reason is, Certain complex features like operator overloading, multiple inheritance, pointers, explicit memory de allocation are not present in Java language.