minor project report

41
MINOR PROJECT REPORT (Project Term August-December, 2012) MOBILE BASED ATTENDANCE TRACKING SYSTEM (J2ME) Submitted By: ASHISH NIVHAL Reg.No. : 10905923 GURBEER KAUR Reg. No. : 10907141 SUMIT SINGH Reg.No.: 10906099 ABHAY NATH SINGH Reg. No.: 10906381 SANJEEV KUMAR Reg.No.: 10906429 SECTION : K3R19 PROGRAMME : B.TECH-MBA (DUAL DEGREE) CSE Under the Guidance of Mr. HARJIT SINGH Lecturer Discipline of CSE/IT Lovely Professional University, Phagwara August to December, 2012

Upload: sanjeev-thakur

Post on 02-Nov-2014

92 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Minor Project Report

MINOR PROJECT REPORT

(Project Term August-December, 2012)

MOBILE BASED ATTENDANCE TRACKING SYSTEM

(J2ME)

Submitted By:

ASHISH NIVHAL Reg.No. : 10905923

GURBEER KAUR Reg. No. : 10907141

SUMIT SINGH Reg.No.: 10906099

ABHAY NATH SINGH Reg. No.: 10906381

SANJEEV KUMAR Reg.No.: 10906429

SECTION : K3R19

PROGRAMME : B.TECH-MBA (DUAL DEGREE) CSE

Under the Guidance of

Mr. HARJIT SINGH

Lecturer

Discipline of CSE/IT

Lovely Professional University, Phagwara

August to December, 2012

Page 2: Minor Project Report

DECLARATION

We hereby declare that the project work entitled (“Mobile Phone Based Attendance

Tracking System”) is an authentic record of our own work carried out as requirements of

Minor Project for the award of degree of B.Tech-MBA(Dual Degree) in CSE from Lovely

Professional University, Phagwara, under the guidance of Mr. Harjit Singh, during August

to December, 2012).

Project Group members: 5

Student 1:

(Ashish Nivhal)

Registration Number: 10905923

Student 2:

(Gurbeer Kaur)

Registration Number: 10907141

Student 3

(Abhay Nath Singh)

Registration Number: 10906381

Student 4:

(Sumit Singh)

Registration Number: 10906099

Student 5:

(Sanjeev Kumar)

Registration Number: 10906429

Page 3: Minor Project Report

CERTIFICATE

This is to certify that the above statement made by the student is correct to the best of my

knowledge and belief.

(Harjit Singh, 14952 , Lecturer)

Faculty Mentor

Page 4: Minor Project Report

ACKNOWLEDGEMENT

This project is a welcome and challenging experience for me as it took a great deal of hard

work and dedication for its successful completion. It’s our pleasure to take this opportunity to

thank all those who help us directly or indirectly in preparation of this report.

We would also like to thank to our project guide Lecturer Mr. Harjit Singh, who supported us

technically as well as morally in every stage of the project. Without his guidance and support,

this project would not have seen light of the day.

We would also like to express a deep sense of gratitude and sincere thanks to Lovely

Professional University.

Last but not the least I thank my family for their boost and support in every sphere. Their

vital push infused a sense of insurgency in me.

Page 5: Minor Project Report

TABLE OF CONTENTS

o Profile of problem

o Existing System

Introduction

Existing Software

What’s new in developing project

o Problem Analysis

Definition

Feasibility Analysis

Project Plan

o Software Requirements

o Design

Flowchart

Description

o Testing

Functional Testing

Structural Testing

Levels of Testing

o Implementation

Conversion Plan

o User manual

o Source code

o Bibliography

Page 6: Minor Project Report

PROFILE OF PROBLEM

In existing system, professor takes the attendance and records the details of absentees or

presenters through UMS. The calculation of student’s attendance each day and the percentage

is done automatically.

The Attendance Section of the UMS helps the students and staff to keep a regular track of

their attendance. The student can check his/her up to date aggregate attendance as well as

course wise attendance as and when required. The parents can also view and check their

ward's attendance status on regular basis.

But main problem is with additional features that UMS provides i.e. a feature for mobiles in the form

of android or window apps but that is only for android compatible mobiles. Though many students

nowadays are using android based mobiles but still many are there which do not use such technology

mobiles.

EXISTING SYSTEM

Introduction

LPU promotes a culture of paperless University. The day to day administration and most of

the University procedures are carried out online. The University Management System

(UMS), an online portal of University, is one such innovative step of the University to

provide vital information regarding academics and other University logistics for assisting the

University students, their parents and the staff. The existing system which is operational and

is similar to our project is the LPU Apps which works on various different platforms like

Windows, Android and Iphone. These applications are available on our University

Management System website. Through these applications we can view our assignments,

attendance, time-table, result etc. In our project which we are developing through the help of

JavaMe, we are developing an application which can run on any Java compatible phone

irrespective of the phone’s operating system. In this application we will be marking the

attendance and also viewing the attendance through any Java compatible phone.

Page 7: Minor Project Report

Existing Software

University Management System (UMS) is a large database system which can be used to

manage, maintain and secure our university’s day to day business. The UMS can be accessed

through the UMS Login available on the University website by logging in using the

Username (student Registration Number in case of students and parents; and Employee ID in

case of staff) and the Password.

For login:

• The students should enter their Registration number as Username and the password.

• The Staff should enter their Employee ID as Username and the password.

In case of the application provided for the phone based environment named “LPUTouch”

which runs on iOS, Android and Windows phone. First the login page comes when we start

the application. After logging in as an authenticated user we can access our attendance, view

marks and see our time table.

What’s new in the system to be developed

In the existing system the application has only been designed for platform like windows,

android and iOS. It does not work on any other phone. But the application which we have

designed can run on any Java enabled device irrespective of the type of OS the phone is

running, thus widening the use of this application. Our project is based on J2ME technology.

PROBLEM ANALYSIS

In this phase we analyze the existing system/product looking for their strength and

weaknesses. For existing we have already mentioned above the various problems with the

system, i.e., it is too hectic to be handled. For example everything involves paperwork like if

we need to check the previous records of the vehicles entered in the premises for the parking

then it usually involves management overheads and registers to manually scroll through every

page and entry to reach a particular record. Whereas in the proposed system the entire

database would be maintained online we just have to make a query from the user interface.

Page 8: Minor Project Report

Product Definition

Mobile phone based attendance tracking system is a J2ME Application developed by using

Midlets and JDBC. It is a mobile app used for marking attendance, updating attendance

records of students, and easy maintenance of record keeping.

Feasibility Analysis

A feasibility study of a system proposal is according to its workability, which is the impact

on the organization, ability to meet their user needs and effective use of resources. Thus when

a new application is proposed it normally goes through a feasibility study before it is

approved for development. Some important features that are to be considered for the

feasibility analysis are:

1. Technical Feasibility - The system must be evaluated from the technical point of view

first. The assessment of this feasibility must be based on an outline design of the

system requirement in the terms of input, output, programs and procedures. The

project should be developed such that the necessary functions and performance are

achieved within the constraints.

Our project is developed using Java/J2ME and JSP and thus it is technically feasible

for development.

2. Economic Feasibility - The developing system must be justified by cost and benefit.

Since the system is being developed as part of project work, there is no manual cost to

spend for the proposed system. Also all the resources are already available, it give an

indication of the system is economically possible for development.

Our project is an app so economically feasible.

3. Behavioural Feasibility – In this we focus on the customer support that whether the

proposed system is sufficient to support the needs.

Our project has taken care of many customer (student-teacher) needs.

Page 9: Minor Project Report

Project Plan

The project aims in implementing software that helps professor to take the attendance using

mobile phone. For this mobile must support java application. This project is based on J2ME

technology. Professor enters the attendance to the mobile using keypad. It is a manual

process. After saving the absentees or presenters in to the mobile, teacher can edit the

attendance list in the mobile. And this attendance details can send to a computer through

servlets. After sending the files to a computer, attendance of students gets updated

automatically.

The project is divided into different sections or modules, to manage these all platforms and

the database association with them, our team has the following people working on different

modules:

ASHISH NIVHAL : Connectivity Module

GURBEER KAUR : Database Module(BACK END)

SUMIT SINGH : User Module (FRONT END)

ABHAY NATH : User Module (FRONT END)

SANJEEV KUMAR : Database Module(BACK END)

As the project is in J2ME, for front end we will be using midlets as an interface for user for

fetching data and showing results. The back end is oracle xe for storage purpose. The

connectivity between these ends has been done through JDBC.

SOFTWARE REQUIREMENTS

Platform : Windows or Linux

Language/Technology : J2ME

Development tools : JDK 1.5 or later, WTK 2.5 or later

Database used : Oracle XE

Technologies used : JSP, JDBC.

Web Server : Glassfish Server 3.1.2 (Apache Tomcat 5.5.9)

Page 10: Minor Project Report

DESIGN

System design is design of components, architecture, modules and interfaces of the system.

It covers the design of each module and its working in brief through Flow charts, Data flow

diagrams.

The data flow diagram of our project is as shown below

Description

1. LOGIN TYPE

a. MARK ATTENDANCE : For teachers to mark attendance of students

b. GET ATTENDANCE : For students to check out their attendance

c. ADMIN : For admin to do changes in database

2. LOGIN

a. USERNAME : For now it is same for all teachers i.e.”Teacher” but in future

changes can be made

Page 11: Minor Project Report

b. PASSWORD : As set by admin can be changed timely, teachers will be

informed about changes explicitly

3. SECTION SELECTION

For selecting among all the sections, which section’s attendance teacher want to mark.

4. ATTENDANCE

This will consist of attendance sheet with students name to mark the attendance

5. DATABASE

For storage purpose, all the attendance to be saved in this, all students attendance

records are updated etc..

TESTING

Software testing is more than just error detection. Testing software is operating the software

under controlled conditions, to (1) verify that it behaves “as specified”; (2) to detect errors,

and (3) to validate that what has been specified is what the user actually wanted.

1. Verification is the checking or testing of items, including software, for conformance

and consistency by evaluating the results against pre-specified requirements.

[Verification: Are we building the system right?]

2. Error Detection: Testing should intentionally attempt to make things go wrong to

determine if things happen when they shouldn’t or things don’t happen when they

should.

3. Validation looks at the system correctness – i.e. is the process of checking that what

has been specified is what the user actually wanted.

[Validation: Are we building the right system?]

Functional Testing

Functional testing is a testing technique that ignores the internal mechanism of the system

and focuses on the output generated against any input and execution of the system. It is also

Page 12: Minor Project Report

called black box testing because it is not concerned about code. Black box testing is often

used for validation.

Functional Testing covers the following focus areas:

Mainline function: Focuses on testing the main functions of the application.

Because of this, mainline function testing often overlaps with other Functional

Testing focus areas.

Error conditions: Testing for error conditions uses inputs that are outside of the

scope of valid parameters and deviate from use cases. This includes exploring

boundary conditions, driving error paths, and displaying all error messages.

Recovery: The purpose of recovery testing is to ensure that the recovery function

meets the recovery requirements. Recovery requirements specify how an

application recovers from an error.

Basic usability: Functional Testing does not include formal usability testing, but

all Functional Testing testers are expected to watch for and report obvious

usability problems that customers might encounter when trying to use the product.

Vulnerability: Functional Testing testers must examine and verify all of the

security elements designed into the system, in the same way the mainline

functions are tested.

Regression: Test cases for important functions are rerun at appropriate points in

every release, even if the functionality was unchanged since the last time the test

was run. A test case might also be rerun once a fix is applied to verify the fix. This

re-verification of previous test cases is called regression testing.

Structural Testing

Structural testing is a testing technique that takes into account the internal mechanism of a

system. It is also called white box testing and glass box testing. It is used for the verification.

Level of Testing:

1. Unit Testing

Page 13: Minor Project Report

Unit testing is a procedure used to validate that a particular module of source code is working

properly. The procedure is to write test cases for all functions and methods so that whenever

a change causes a regression, it can be quickly identified and fixed.

Benefits:

The goal of unit testing is to isolate each part of the program and show that the individual

parts are correct. Unit testing provides a strict, written contract that the piece of code must

satisfy. As a result, it affords several benefits:

a) Facilitates Change

b) Simplifies Integration

c) Documentation

d) Separation of Interface from Implementation

2. Integrated Systems Testing

Integrated System Testing (IST) is a systematic technique for validating the construction of

the overall Software structure while at the same time conducting tests to uncover errors

associated with interfacing. The objective is to take unit tested modules and test the overall

Software structure that has been dictated by design. IST can be done either as Top down

integration or Bottom up Integration.

3. System Testing

System testing is testing conducted on a complete, integrated system to evaluate the

system’s compliance with its specified requirements. System testing falls within the scope

of Black box testing, and as such, should require no knowledge of the inner design of the

code. System testing is actually done to the entire system against the Functional

Requirement Specifications (FRS) and/or the System Requirement Specification (SRS).

Moreover, the System testing is an investigatory testing phase, where the focus is to have

almost a destructive attitude and test not only the design, but also the behaviour and even

the believed expectations of the customer. It is also intended to test up to and beyond the

Page 14: Minor Project Report

bounds defined in the software/hardware requirements specifications. Remaining All

Testing Models comes under System Testing

4. User Acceptance Testing

User Acceptance Testing (UAT) is performed by Users or on behalf of the users to ensure

that the Software functions in accordance with the Business Requirement Document. UAT

focuses on the following aspects

All functional requirements are satisfied.

All performance requirements are achieved.

Other requirements like transportability, compatibility, error recovery etc. are satisfied.

Acceptance criteria specified by the user is met.

IMPLEMENTATION

The project has been divided into following modules :

1. User Module:

The main purpose of the user module is to provide security. This module is specially

designed for staffs, which use mobile phone to take attendance. Each staff enter username

and password before enter in to attendance list. If username and password cannot match,

he/she can’t enter in to attendance page.

It is also for students who need to know their attendance.

2. Attendance Entry Module:

The purpose of Attendance Entry Module is to mark the attendance using cell phone. In this

module Lecturer takes the attendance using the cell phone. Lecturers select the section. After

this session he enters in to attendance page. Here staff makes a mark on the absentees.

3. Connectivity Module:

Page 15: Minor Project Report

The main function of this module is it sends attendance list to the server database. In this

module connectivity is made between front end & back end i.e. database.

4. Updating the Database Module:

The first function of this module is to update the attendance list from the cell phone. When

the attendance list from the cell phone receives, server automatically updates its database.

The server updating the database whether any change from cell phone occurred.

5. Display Module:

The Displaying attendance list Module deals with the WEB application of J2ME. In this

module Students can view their attendance through this app. Student must provide their

registration number then they get their attendance.

CONVERSION PLAN

In the future, many additional features can be added such as viewing time table, results etc.

Some changes can be made to make it more efficient & quick in accessing or maintaining

database.

USER MANUAL

Following are some snapshots telling the user how to use this app.

1.

Page 16: Minor Project Report

Fig: App Launch

2.

Page 17: Minor Project Report

Fig: Login type

3.

Fig: Login (Mark Attendance)

4.

Page 18: Minor Project Report

Fig: Unsuccessful login

5.

Fig: Section Selection (if successful login)

6.

Page 19: Minor Project Report

Fig: Attendance List

7. Clicking “SAVE” will save the attendance in database.

8.

Fig: Login (Get Attendance)

9.

Page 20: Minor Project Report

Fig: Alert message(Attendance)

SOURCE CODE

Midlet Code:

import java.io.*;

import java.util.*;

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

import javax.microedition.io.*;

import java.lang.StringBuffer;

public class Login extends MIDlet implements CommandListener {

private String user;

private String url = "http://localhost:8080/Connect/getConnection";

private Display display;

Page 21: Minor Project Report

private Command exit = new Command("EXIT", Command.EXIT, 1);;

private Command connect = new Command("Connect", Command.SCREEN, 1);

private Command cancel = new Command("Cancel", Command.CANCEL, 2);

private Command find = new Command("Search", Command.OK, 2);

private Command ok = new Command("Lets Go!!",Command.SCREEN,1);

private Command choose, back;

private Form menu1, menu, form, form1, form2, form3, markat;

private TextField username, password, reg;

private Alert alert;

private ChoiceGroup marklist;

private List secn, choice;

DBConn db;

Attend at;

Mark m;

public Login() throws Exception {

display = Display.getDisplay(this);

}

public void startApp() {

displayMenu();

}

Page 22: Minor Project Report

public void displayMenu() {

choice = new List("CHOOSE",List.EXCLUSIVE);

choice.append("Mark Attendance", null);

choice.append("Get Attendance", null);

choice.append("R U THE BOSS!!", null);

choice.addCommand(ok);

choice.addCommand(exit);

choice.setCommandListener(this);

display.setCurrent(choice);

}

public void pauseApp() {}

public void destroyApp(boolean unconditional) {}

public void commandAction(Command command, Displayable screen) {

if(command == ok && screen == choice){

int i = choice.getSelectedIndex();

String opt = choice.getString(i);

if(opt.equals("Mark Attendance") ){

menu1 = new Form("Connect");

username = new TextField("Please input username: ","",30,TextField.ANY);

password= new TextField("Please input password: ","",30,TextField.PASSWORD);

Page 23: Minor Project Report

menu1.append(username);

menu1.append(password);

menu1.addCommand(exit);

menu1.addCommand(connect);

menu1.setCommandListener(this);

display.setCurrent(menu1);

}

else if(opt.equals("Get Attendance")){

menu = new Form("Student Domain");

reg = new TextField("Enter Registration Number","",30,TextField.ANY);

menu.append(reg);

menu.addCommand(ok);

menu.addCommand(exit);

menu.setCommandListener(this);

display.setCurrent(menu);

}

else if(opt.equals("R U THE BOSS!!")){

menu1 = new Form("WELCOME ADMIN");

username = new TextField("Verification ID: ","",30,TextField.ANY);

password = new TextField("Password: ","",30,TextField.PASSWORD);

menu1.append(username);

menu1.append(password);

menu1.addCommand(exit);

Page 24: Minor Project Report

menu1.addCommand(connect);

menu1.setCommandListener(this);

display.setCurrent(menu1);

}

}

if(command == ok && screen == menu){

}

if (command == exit) {

destroyApp(false);

notifyDestroyed();

}

else if (command == connect && screen == menu1) {

if(username.getString().equals("") || password.getString().equals("")){

alert = new Alert("Error", "You should enter username and password.", null,

AlertType.ERROR);

alert.setTimeout(Alert.FOREVER);

display.setCurrent(alert);

}

else if(username.getString().equals("Teacher")&& password.getString().equals("1111")){

db = new DBConn(this);

db.start();

}

else if(username.getString().equals("Rocker")&& password.getString().equals("shine"))

Page 25: Minor Project Report

{

alert = new Alert("Welcome","Hello Admin!!",null,AlertType.CONFIRMATION);

alert.setTimeout(Alert.FOREVER);

display.setCurrent(alert);

}

else

{

alert = new Alert("Error","Invalid Access",null,AlertType.ERROR);

alert.setTimeout(Alert.FOREVER);

display.setCurrent(alert);

}

}

}

public class DBConn implements CommandListener, Runnable {

Login midlet;

private Display display;

private int index;

public DBConn(Login midlet) {

this.midlet = midlet;

display = Display.getDisplay(midlet);

}

public void start() {

Page 26: Minor Project Report

Thread t = new Thread(this);

t.start();

}

public void run() {

StringBuffer sb = new StringBuffer();

HttpConnection c;

try {

c = (HttpConnection) Connector.open("http://localhost:8080/Connect/getConnection");

c.setRequestProperty("User-Agent","Profile/MIDP-2.0, Configuration/CLDC-1.1");

c.setRequestProperty("Content-Language","en-US");

c.setRequestMethod(HttpConnection.POST);

DataOutputStream os = (DataOutputStream)c.openDataOutputStream();

os.flush();

os.close();

DataInputStream is =(DataInputStream)c.openDataInputStream();

char ch = (char) is.read();

if(ch == '1')

attend();

else

{

Alert a = new Alert("");

a.setString("Connection error "+ch);

Page 27: Minor Project Report

a.setTimeout(Alert.FOREVER);

display.setCurrent(a);

}

is.close();

c.close();

} catch (Exception e) {

Alert a = new Alert("");

a.setString(e.toString());

a.setTimeout(Alert.FOREVER);

display.setCurrent(a);

}

}

private void attend() {

secn = new List("Select Section",List.EXCLUSIVE);

back = new Command("Back", Command.BACK, 1);

ok = new Command("Go",Command.SCREEN,1);

secn.append("K3R19", null);

secn.append("KE007", null);

secn.append("KR101", null);

secn.append("K1R10", null);

Page 28: Minor Project Report

secn.addCommand(ok);

secn.addCommand(back);

secn.setCommandListener(this);

display.setCurrent(secn);

}

public void commandAction(Command c, Displayable d) {

if (c == ok) {

String sec;

int i = secn.getSelectedIndex();

sec = secn.getString(i);

at = new Attend(midlet,sec);

at.start();

}

else if(c == back){

display.setCurrent(form);

}

}

}

public class Attend implements CommandListener, Runnable{

Login midlet;

String section[] = new String[100];

int i=0;

Page 29: Minor Project Report

private Display display;

String s;

private int index =0;

public Attend(Login midlet, String sec) {

this.midlet = midlet;

this.s = sec;

display = Display.getDisplay(midlet);

}

public void start() {

Thread t1 = new Thread(this);

t1.start();

}

public void run() {

StringBuffer sb1 = new StringBuffer();

HttpConnection c1 = null;

try {

c1 = (HttpConnection) Connector.open("http://localhost:8080/Connect/mrkAttendance");

c1.setRequestProperty("User-Agent","Profile/MIDP-2.0, Configuration/CLDC-1.1");

c1.setRequestProperty("Content-Language","en-US");

c1.setRequestMethod(HttpConnection.POST);

DataOutputStream od = (DataOutputStream)c1.openDataOutputStream();

Page 30: Minor Project Report

od.writeUTF(s);

od.flush();

od.close();

DataInputStream id =(DataInputStream)c1.openDataInputStream();

char ch; int r;

while(( r = id.read())!= -1){

ch = (char)r;

if(ch != ' '){

sb1.append(ch);

section[i] = sb1.toString();

}else if(ch == ' ')

{

i++;

sb1 = new StringBuffer();

}

else

continue;

}

i=1;

markat = new Form("Mark Attendance");

marklist = new ChoiceGroup("Students", Choice.MULTIPLE);

back = new Command("Back", Command.BACK, 1);

ok = new Command("Save", Command.OK, 2);

Page 31: Minor Project Report

while(section[i] != null)

{

marklist.append(section[i], null);

i++;

}

markat.append(marklist);

markat.addCommand(back);

markat.addCommand(ok);

markat.setCommandListener(this);

display.setCurrent(markat);

c1.close();

id.close();

} catch (Exception e) {

Alert a = new Alert("");

a.setString(e.toString());

a.setTimeout(Alert.FOREVER);

display.setCurrent(a);

}

}

public void commandAction(Command c, Displayable d) {

Page 32: Minor Project Report

int q=1; int k=0;

String att[] = new String[100];

if(c==ok && d==markat){

while(!marklist.equals(null))

{

if(marklist.isSelected(q) == true){

att[k] = marklist.getString(q);

k++;

}

q++;

}

m = new Mark(midlet,att);

m.start();

}

else if(c==back)

display.setCurrent(secn);

}

}

public class Mark implements Runnable{

Login midlet;

Page 33: Minor Project Report

private Display display;

String[] p = new String[100];

public Mark(Login midlet, String sec[]) {

this.midlet = midlet;

this.p = sec ;

display = Display.getDisplay(midlet);

}

public void start() {

Thread t1 = new Thread(this);

t1.start();

}

public void run() {

StringBuffer sb1 = new StringBuffer();

HttpConnection c1 = null;

int m=0;

while(p!=null){

try {

c1 = (HttpConnection) Connector.open("http://localhost:8080/Connect/savAttendance");

c1.setRequestProperty("User-Agent","Profile/MIDP-2.0, Configuration/CLDC-1.1");

c1.setRequestProperty("Content-Language","en-US");

c1.setRequestMethod(HttpConnection.POST);

Page 34: Minor Project Report

DataOutputStream od = (DataOutputStream)c1.openDataOutputStream();

od.writeUTF(p[m]);

od.flush();

od.close();

}catch(Exception e){

Alert a = new Alert("");

a.setString(e.toString());

display.setCurrent(a);

}

m++;

}

try{

DataInputStream id =(DataInputStream)c1.openDataInputStream();

char c =(char) id.read();

if(c == '1'){

Alert a = new Alert("");

a.setString("Attendance marked");

display.setCurrent(a);

}

}catch(Exception e){

Alert a = new Alert("");

a.setString(e.toString());

display.setCurrent(a);

Page 35: Minor Project Report

}

}

}

}

2. Servlet Programming:

1. Database connectivity check

import java.io.*;

import java.text.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class getConnection extends HttpServlet {

public void doPost(HttpServletRequest request,HttpServletResponse response) throws

ServletException, IOException {

DataInputStream in = new DataInputStream((InputStream)request.getInputStream());

int message= 0;

PrintWriter out = null;

Connection conn = null;

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

Page 36: Minor Project Report

conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","shinni

ng");

message = 1;

response.setContentType("text/plain");

response.setContentLength(message);

out = response.getWriter();

out.println(message);

out.flush();

out.close();

conn.close();

}

catch (Exception e) {

message = 3;

out.println(message);

}

in.close();

}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

doPost(request,response);

} }

Page 37: Minor Project Report

2. Attendance list generation

import java.io.*;

import java.text.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class mrkAttendance extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

DataInputStream in = new DataInputStream(request.getInputStream());

boolean b;

String sec = in.readUTF();

String message = "";

PrintWriter out = null;

Connection conn = null;

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","shinni

ng");

PreparedStatement s = conn.prepareStatement("Select sname from student where section = ?

order by reg_no");

s.setString(1,sec);

Page 38: Minor Project Report

ResultSet rs = s.executeQuery();

while(b = rs.next())

{

if(b)

message += " "+rs.getString("sname").trim();

}

response.setContentType("text/plain");

response.setContentLength(message.length());

out = response.getWriter();

out.println(message);

out.flush();

out.close();

conn.close();

}

catch (Exception e) {

message = "......";

out.println(message);

}

in.close();

}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

Page 39: Minor Project Report

doPost(request,response);

}

}

3. Saving Attendance

import java.io.*;

import java.text.*;

import java.util.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class savAttendance extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

DataInputStream in = new DataInputStream(request.getInputStream());

String sn = "Sanjay";

int message=0, m = 0;// ="jdbc:oracle:thin:@localhost:80:xe";

PrintWriter out = null;

Connection conn = null;

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

Page 40: Minor Project Report

conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","shinni

ng");

PreparedStatement s1 = conn.prepareStatement("Select reg_no, section from student where

sname = ?");

s1.setString(1,sn);

ResultSet r = s1.executeQuery();

while(r.next()){

PreparedStatement s = conn.prepareStatement("Update at_detail set l_att = ? where r_no =

?");

s.setInt(1, m+1);

s.setInt(2,r.getInt("reg_no"));

int rs = s.executeUpdate();

PreparedStatement s2 = conn.prepareStatement("Update at_detail set l_del = ? where sec=

'KR101'");

s2.setInt(1,m+1);

s2.setString(2,r.getString("section"));

int rs1 = s2.executeUpdate();

message = 1;

}

response.setContentType("text/plain");

response.setContentLength(message);

out = response.getWriter();

out.println(message);

Page 41: Minor Project Report

out.flush();

out.close();

conn.close();

}

catch (Exception e) {

message = 3;

out.println(message);

}

in.close();

}

public void doGet(HttpServletRequest request,HttpServletResponse response) throws

ServletException, IOException {

doPost(request,response);

}

}

BIBLIOGRAPHY

1. http://j2mesamples.blogspot.com/2009/02/database-connection-using-j2me.html

2. http://www.roseindia.net/j2me/check-box.shtml

3. http://www.youtube.com/watch?v=YbXmFp8wRDw&feature=related

4. http://docs.oracle.com/cd/B14099_19/wireless.1012/b13819/j2meprov.htm

5. http://www.zimbra.com/forums/zimbrame-j2me-client/20004-how-resolve-javax-

microedition-io-connectionnotfoundexception-tcp-exception.html