BCA - III Project Report
BCA - III Project Report
Developed By
CERTIFICATE
2
System Analysis & Configuration
3
Project Contents
1. Introduction to Java 7
2. Basic of Oops 10
3. JDBC 19
5. Project Introduction 23
6. Project Snapshots 24
8. Bibliography 39
4
5
1. INTRODUCTION TO JAVA
Java is an object oriented programming language that was designed to meet the need
for a platform independent language. Java is used to create applications that can run
on a single computer as well as a distributed network. Java is both a language and a
technology used to develop stand –alone and internet-based applications.
6
The java language contains built-in-support for the World Wide Web (WWW),
which is a service of the internet to retrieve information in the form of Web pages.
The primary motive behind developing java language was the need for a portable
and platform-independent language that could be used to produce code that would
run on a variety of control processing unit (CPU) under different environments. We
can use java to develop network-oriented programs because networking features are
built in features in java. Java is simple, object-oriented, compiled and
interpreted, portable, distributed and a secure language.
The JVM forms the base for the java platform and is convenient to use on various
hardware-based platforms.
7
Components of the JVM
JVM for different platforms uses different techniques to execute the Bytecode. The
major components of JVM are:
1. Class loader
2. Execution engine
3. Just In Time (JIT) compiler.
1. Class Loader: The class loader loads the class files, which are required by a
program running in the memory. The classes are loaded dynamically when required
by the running program. A JVM can have following types of class loaders:
1.1 Primordial Class Loader: Loads the Java API classes required by the running
Java program.
8
1.2 Class Loader Objects: Loads the classes of the Java application program. An
application can create class loaders at runtime for loading the classes of the
application.
2. Execution Engine: The Java execution engine is the component of the JVM that
runs the Bytecode one line after another. The execution engines implemented by
different vendors use different techniques to run the Bytecode. The Java execution
engine converts the Bytecode to the machine object code and runs it.
3. JIT Compiler: The JIT compiler is used for compiling the Bytecode into
executable code. The JVM runs the JIT compiled code without interpreting because
the JIT-compiled code is in the machine code format. Running the JIT-compiled
code is faster than running the interpreted code because it is compiled and does not
require being run, line after line.
9
memory allocated as soon as it is created. Classes form the templates for
creating objects. In addition to this, abstraction enables to provide a
restricted access to data. In object-oriented programming, abstraction means
ignoring the non-essential details of an object and concentrating on its
essential features.
10
Run time errors occur during the execution of a program.
These can occur due to Running out of memory, Resource allocation errors,
Inability to find files, or Problem in network connectivity.
EXCEPTION CLASSES: To handle exceptions, the java run-time system
searches for an exception-handler. In java, a catch statement is an exception
handler that is used to handle an exception. The search for an exception
handler begins with the method in which the exception is raised. If no
appropriate exception-handler is found, the java run-time system searches
the exception-handler in the next higher method hierarchy. The type of
exception handled by the exception-handler should match the type of
exception thrown. The java run-time system proceeds with the normal
execution of the program after an exception gets handled. If no appropriate
exception-handler is found by the java run-time system, the program is
terminated.
In java, Throwable class is the superclass of all the
exception classes. Object class is the base class of the exception
hierarchy. The Exception class and the Error class are two subclasses of
the Throwable class. Exception handling can be implemented by using
try, catch, throw, throws and finally keywords available in java.
11
AWT (ABSTRACT WINDOW TOOLKIT)
Java provides the AWT control components, which contains classes that enable us to
create standard components, such as buttons, labels, and text fields in java. A java
component enables us to accept input from an end user. We can position AWT
components in containers using the different layout managers.
12
the Component class. the Component class provides the add() method to add AWT
components, such as an applet or a window, to containers. The various classes that
we can use for creating AWT controls are:
1. TextField Class: Text Fields are user interface components that accept
text input from end user. A text field enables us to type text in a single
line.
2. TextArea Class: Text areas are also used to accept text input from an
end user, but it enables us to type text in multiple lines.
3. Button Class: Buttons are AWT controls that are used for handling
events. Java provides the Button class to create AWT button components.
4. List Class: List control is a scrollable list of text items that enables us to
select either one item or multiple items. We can create a list using the
List class in java.
5. CheckBox Class: Check boxes are the components that exist in dual
state, checked and unchecked. We can change the state of a check box by
clicking the check box. We can create a check box by using CheckBox
class.
6. Label Class: Labels are used for displaying a single line of text in a
container. We can create a label by using Label class.
13
Swing components contain the Pluggable Look And
Feel (PL&F) feature that allows applications to have the same behavior on
various platforms.
14
frames, buttons, and check boxes. The various top-level swing
containers are:
A. JFRAME
B. JAPPLET
C. JDIALOG
A. JPanel
B. JtabbedPane
C. JscrollPane
D. JToolBar
A. JTextField
B. JComboBox
C. JCheckBox
D. JButton
E. JLabel
F. JTable
15
EVENT-HANDLING IN JAVA
16
event source can generate various types of events depending upon the
change of state of the event source.
17
18
JAVA DATA BASE CONNECTIVITY (JDBC)
19
THE JDBC-ODBC BRIDGE DRIVER
The JDBC-ODBC Bridge driver is called the Type-1 driver. The JDBC-
ODBC Bridge driver converts JDBC calls to Open Database Connectivity
(ODBC) calls. ODBC is an open standard API to communicate with
databases. The JDBC-ODBC bridge driver enables a Java application to use
any database that supports ODBC driver. A Java application cannot interact
directly with the ODBC driver. For this reason, the application uses the
JDBC-ODBC Bridge driver that works as an interface between the
application and the ODBC driver. To use the JDBC-ODBC Bridge driver
you need to have the ODBC driver installed on the client computer. The
JDBC-ODBC Bridge driver is usually used in stand-alone applications. The
following figure shows the working of JDBC-ODBC Driver:
20
21
PROJECT DETAILS
22
1) Opening Page of our calculator
23
Coding of the project
24
import java.awt.*;
import java.awt.event.*;
class ss extends Frame implements ActionListener{
int a=0,b=0,c=0,i=0;
TextField tf;
Button b1,b2,b3,b4,b5,b6,b7,b8,b9,b0;
Button badd,bsub,bmul,bdiv,bexit,bequal;
ss(){
setLayout(new BorderLayout());
setSize(300,300);
Panel p1 = new Panel(new GridLayout(1,1));
Panel p2 = new Panel(new GridLayout(4,4));
tf=new TextField(10);
p1.add(tf);
b1=new Button("1");
b2=new Button("2");
b3=new Button("3");
b4=new Button("4");
b5=new Button("5");
b6=new Button("6");
b7=new Button("7");
b8=new Button("8");
b9=new Button("9");
b0=new Button("0");
badd=new Button("+");
bsub=new Button("-");
bmul=new Button("*");
bdiv=new Button("/");
bexit=new Button("exit");
bequal=new Button("=");
p2.add(b1);
p2.add(b2);
25
p2.add(b3);
p2.add(b4);
p2.add(b5);
p2.add(b6);
p2.add(b7);
p2.add(b8);
p2.add(b9);
p2.add(b0);
p2.add(badd);
p2.add(bsub);
p2.add(bmul);
p2.add(bdiv);
p2.add(bexit);
p2.add(bequal);
add(p1,BorderLayout.NORTH);
add(p2,BorderLayout.CENTER);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b0.addActionListener(this);
badd.addActionListener(this);
bsub.addActionListener(this);
bmul.addActionListener(this);
bdiv.addActionListener(this);
bexit.addActionListener(this);
bequal.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
String s=ae.getActionCommand();
26
if(s.equalsIgnoreCase("exit"))
System.exit(0);
if(s.equalsIgnoreCase("1"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("2"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("3"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("4"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("5"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("6"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("7"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("8"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("0"))
tf.setText(tf.getText()+s);
if(s.equalsIgnoreCase("+"))
{ i=1;
a=Integer.parseInt(tf.getText());
tf.setText("");
}
if(s.equalsIgnoreCase("-"))
{ i=2;
a=Integer.parseInt(tf.getText());
tf.setText("");
}
if(s.equalsIgnoreCase("*"))
{ i=3;
a=Integer.parseInt(tf.getText());
27
tf.setText("");
}
if(s.equalsIgnoreCase("/"))
{ i=4;
a=Integer.parseInt(tf.getText());
tf.setText("");
}
if(s.equalsIgnoreCase("="))
{
b=Integer.parseInt(tf.getText());
switch(i){
case 1:
c=a+b;
break;
case 2:
c=a-b;
break;
case 3:
c=a*b;
break;
case 4:
c=a/b;
break;
}
tf.setText(""+c);
}
}
}
class calculater{
public static void main(String args[]){
ss a1= new ss();
a1.setVisible(true);
}}
28
BIBLOGRAPHY
8. www.java.sun.com
9. www.w3schools.org
10.www.google.co.in
11.www.javaranch.com
29