Thursday, May 6, 2010

Mumbai`s Murderer Get Death Sentence

After 17 months of long lawful trial finally the lone captured terrorist Ajmal Kasab of  26/11 was sentenced to death though anyone`s death is not a thing to rejoice or cheer about this man is not human his deed were inhumane.He butchered people and murdered with great joy.Kasab killed more then 70 people alone at one of railway station of Mumbai then killed city`s top three cops and also conspirated in the largest ever terror strike on India.
I watched the 26/11 in my TV set but every second of it really frightened me and also raged me with anger against these terrorists.
When someone dies we say may his soul rest in peace but I curse him that may his soul never get peace his soul should be burn in hell and he should re-born as goat who would be butchered a thousand times

Mr Deeds -An awesome Movie

Even tough my university exams are approaching I still went onto watch movies continuously. first I watched Madagaskar Escape 2 Africa then I watched Mr Deeds,and let me tell you I really liked the movie ,it was amazing which depicted only one  notion and that is do the god work and spread happiness in everyones life.It was a great story where a  guy from small little town becomes heir of  a damm rich billionaire who leaves $40 Billion for his heir and then how the other company members try to sell of company and this guy named Mr Deeds the heir was fooled but he spread sense of  happiness and goodness in all.
What I learnt from the movie is that we should do what we always dream of and things would then start falling in place and if we try running behind just for sake of materialistic happiness then we are bound to be doomed.

Wednesday, April 28, 2010

Edesia -The Latest Project on Cards

It all start with a small circle of life which brought me my first "commercial" project of CMS development.It`s about a food and beverage consultancy firm named EDESIA Ventures who wanted a website and they came in contact with D2C a startup from few students of CBS College for whom I developed some posters and did online publicity during their fest and this D2C is started by the fest`s organizer so they recalled me through Harsh(my best friend).

Tough I agreed and quoted my prices according to the Restaurant Firm and started developing for same but when I went with D2C to the clients we both realized they wanted a website for the consultancy firm :) and everything just got messed up but then I didn`t wanna loose the project so I presented them with CMS and somehow wanted to compensate on my quote as I have quoted prize for HTML stuff but I didn`t wanna spoil D2C image nor mine so ..............

I know it`s not a good business tactic but I think I`l do better next time,then what more on 23rd I had to begin on prototype and today I showed them and it was accepted and I was able to win their confidence.
The protype is still in development stage I`l reveal the URL as soon as it gets online for world

Monday, April 26, 2010

More JAVA Notes

Friends I have searched for some e-books and notes of various authors and college i will be soon be posting them here
below i have posted a link do download it its an e-book of guide to java,may come handy

Click to download E-book

Friday, April 23, 2010

IP university BCA`s JAVA`s special Notes

What is JDBC?

The JDBC ( Java Database Connectivity) defines an application programming interfaces and classes for connecting java programs with database.

Using JDBC programmers can send SQL, PL/SQL statements to almost any relational database. JDBC can be used for executing SQL statements. It supports the basic SQL functionality. It provides RDBMS access by allowing programmers to embed SQL inside Java code.

JDBC Architecture

JDBC drivers

JDBC drivers are divided into four types . The different types of jdbc drivers are:

Type 1: JDBC-ODBC Bridge driver (Bridge)
Type 2: Native-API/partly Java driver (Native)
Type 3: AllJava/Net-protocol driver (Middleware)
Type 4: All Java/Native-protocol driver (Pure)

Type 1: JDBC-ODBC Bridge driver

The Type 1 driver translates all JDBC calls into ODBC calls and sends them to the ODBC driver.

Advantage

The JDBC-ODBC Bridge allows access to almost any database, since the database's ODBC drivers are already available.

Disadvantages

1. Since the Bridge driver is not written fully in Java, Type 1 drivers are not portable.
2. They are the slowest of all driver types.
3. The client system requires the ODBC Installation to use the driver.
4. Not good for the Web.

Type 2: Native-API/partly Java driver

The Type 2 drivers convert JDBC calls into database-specific calls. This driver is specific to a particular database. Example: Oracle will have oracle native API. (native API means Database Library API)


Advantage

The Type 2 JDBC drivers offer better performance than the Type 1.This is because of two reasons

1. The layers of communication in Type 2 are less than that of Type 1 .

2. It uses Native API which is Database specific.

Disadvantage

1. Native API must be installed in the Client System and hence type 2 drivers cannot be used for the Internet.

2. Like Type 1 drivers, it’s not written in Java Language which forms a portability issue.

3. If we change the Database then we have to change the native API as it is specific to a database

Type 3: All Java/Net-protocol driver

Type 3 drivers accepts calls from JDBC and passed through the network to the middle-tier server(middleware component). The middle-tier then translates the request to the database. The middle-tier server can in turn use Type1, Type 2 or Type 4 drivers.

Advantage

1. This driver is server-based, so there is no need for any vendor database library to be present on client machines.
2. This driver is fully written in Java and hence Portable. It is suitable for the web..
3. The net protocol can be designed to make the client JDBC driver very small and fast to load.
4. This driver is very flexible allows access to multiple databases using one driver.
5. They are the most efficient amongst all driver types.

Disadvantage

It requires another server application to install and maintain. Traversing the recordset may take longer, since the data comes through the backend server.

Type 4 : Native-protocol/all-Java driver

The Type 4 driver uses java networking libraries to communicate directly with the database server.

Advantage

1. The major benefit of using a type 4 JDBC drivers are that they are completely written in Java to achieve platform independence

2. It is most suitable for the web.

3. Number of translation layers is very less i.e. Type 4 JDBC drivers don't have to translate database requests to ODBC or a native connectivity interface or to pass the request on to another server.

4. performance is also good.
3. No need to install special software on the client or server. Further, these drivers can be downloaded dynamically.

Disadvantage

With type 4 drivers, the user needs a different driver for each database.

Java Database Connectivity Steps

1. Before creating a java jdbc connection to the database, programmers must first import the java.sql package.

import java.sql.*;

2. . Loading a database driver.

Programmers can load the driver class (java.sql.Driver) by calling the method Class.forName() .This method has Driver class name as an argument. Class is a class in java.lang package.

Syntax for loading driver

try

{

Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);

}

catch(Exception x)

{

System.out.println( “Unable to load the driver class!” );

}

3. Creating a Connection

The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver.DriverManager is considered the backbone of JDBC architecture. DriverManager class manages the JDBC driver.

DriverManager’s getConnection() method is used to establish
a connection to a database.

Syntax:

DriveManager.getConnection(URL). The URL always has three parts.

Protocol:subprotocol:subname

Protocol is always JDBC.

Subprotocol is used for specifying the type of driver .

Example:If the driver is JDBC-ODBC bridge then the subprotocol must be odbc.

Subname is used to identify the database.

4.Creating Connection object

Once a connection is obtained user can interact with the database.For the interaction with the database Java implements Connection interface.The methods defined in the Connection interface helps programmer to interact with the database through the established connection ( DriveManager.getConnection) .

ie Connection c=DriveManager.getConnection(URL)

5.Creating Statement object

Statement is an interface defined in sql package.This interface has createStatement() method.This method helps to creates an SQL statement object from the Connection object .

ie Statement st=c.createStatement();

The Statement object st is used to send and execute SQL statements to a database.

6.Executing SQL statements using Statement interface

Statement interface defines three methods to execute the SQL statements.

They are

1. executeQuery()- executes SELECT statement .

2. executeUpdate()-executes statements that create or modify tables,

3. execute()-executes an SQL statement that is written as String object

ie st.executeQuery("select * from Employees");

executing the SQL statement and sendind to database using st.

7.Resultset

Resultset is an interface defined in sql package. It provides access to a table of data generated by executing a Statement interface. When we execute a SELECT statement with the executeQuery() method, it will return a Resultset object. The data in a ResultSet object is organized in rows and columns.

ie r=st.executeQuery("select * from Employees");

In the above statement r is pointing to the Employees table.

Resultset defines a method next().

r.next() - Move the cursor to the first row

Example :

Connecting MS-Access database using JDBC

import java.sql.*;

public class jdbc1

{

public static void main(String args[])

{

ResultSet r;

try

{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection c=DriverManager.getConnection("jdbc:odbc:emp");

Statement st=c.createStatement();

r=st.executeQuery("select * from Employees");

while(r.next())

{

System.out.println(r.getInt(1)+"\t"+r.getString(2)+"\t"+r.getInt(3)+"\t"+r.getString(4));

}

}

catch(SQLException e)

{

System.out.println("SQL Error");

}

catch(Exception e)

{

System.out.println("Error" +e);

}

}

}

output:

C:\Program Files\Java\jdk1.5.0_07\bin>javac jdbc1.java

C:\Program Files\Java\jdk1.5.0_07\bin>java jdbc1

1 MCA 122 ee

2 MBA 125 hh

Important points

1. what are the differences between ODBC and JDBC?

1.ODBC(OpenDatabaseConnectivity) is for Microsoft and JDBC(Java DatabaseConnectivity) is for java applications.

2.ODBC can't be directly used with Java because it uses a C

Interface

3.ODBC makes use of pointers which have been removed

totally from java.

4.ODBC requires manual installation of the ODBC driver

manager and driver on all client machines.JDBC drivers are

written in java and JDBC code is automatically

installable,secure,and portable on all platforms.

5.ODBC is procedural oriented and JDBC is object oriented.

2.Explain the different drivers in java?

3.Create databaseconnectivity using JDBC?