You are on page 1of 13

DEPARTMENT:ETE

ONLINE SURVEY SYSTEM

Course Code:18PD13
Course Name:Java Programming

MINI PROJECT
REPORT

20T102

BHARATH KUMAR K
CONTENTS
 ABSTRACT

 OBJECTIVE

 PROBLEM STATEMENT

 DATAFLOW DIAGRAM

 SAMPLE CODING

 SCREEN SHOT
ABSTRACT

The proposed online project is an implementation of Java


programming language for software generation that is important
in college or organization to carry survey. In this system of survey, only
the users authenticated by admin from the database system can drop
their vote or express their viewpoint regarding the issue. Being online
software, it can be logged on from anywhere with internet access.

OBJECTIVE

Online Survey System Project is a web-based application


developed in Java programming language to facilitate online survey.
The main aim of the project is to form a platform to collect the
viewpoints of related people about certain issue using the internet.
Along with launching survey, it is capable of giving e-mail
notifications. It can be implemented in any organizations or college for
carrying out survey of any kind.

PROBLEM STATEMENT

In order to take any decision in an organization, it is essential to


know what actually workers or the members of organization want. It
may not possible to listen to everybody separately and sometimes the
viewpoints are required to be kept secret. Also, the manual system of
survey is tedious and time consuming as well as uneconomical. So, an
online survey system is the solution of these existing problems.
DATA FLOW

SAMPLE CODING

Question.java

package beans;
import javax.faces.bean.ManagedBean;
import javax.faces.model.SelectItem;
@ManagedBean
public class Question {
private String id, text, answer;
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
public SelectItem[] getOptions() {
return options;
}
public void setOptions(SelectItem[] options) {
this.options = options;
}
private SelectItem options[] = new SelectItem[3];
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Question() {
}
public Question(String id, String text, String opt1, String
opt2, String opt3) {
this.id = id;
this.text = text;
this.options[0] = new SelectItem(1,opt1);
this.options[1] = new SelectItem(2,opt2);
this.options[2] = new SelectItem(3,opt3);
}
}

Tpoic.java:
package beans;
import dao.TopicDAO;
import java.util.ArrayList;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
public class Topic {
private String title, id;
private ArrayList<Question> questions = null;
private int position = 0;
public int getPosition() {
return position;
}
public Topic() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}

public void setTitle(String title) {


this.title = title;
}
public Topic(String id, String title) {
this.title = title;
this.id = id;
}
public String process() {
// get questions for the selected topic
position = 0;
questions = TopicDAO.getQuestions(id);
return "survey";
}
public ArrayList<SelectItem> getTopics() {
ArrayList<Topic> lst = TopicDAO.getTopics();
ArrayList<SelectItem> items = new
ArrayList<SelectItem>();
for ( Topic t : lst)
items.add( new SelectItem( t.getId(), t.getTitle()));
return items;
}
public Question getQuestion() {
return questions.get(position);
}
public int getQuestionCount() {
return questions.size();
}

public void next(ActionEvent evt) {


position ++;
}
public void previous(ActionEvent evt) {
position --;
}
public String cancel() {
return "index";
}
public String finish() {

boolean done = TopicDAO.storeSurveyResults(id,


questions);
if ( done )
return "finish";
else
return "error";
}
}

Database.java

package dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class Database {
public static Connection getConnection() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe",
"survey","survey");
return con;
}
catch(Exception ex) {
System.out.println("Database.getConnection() Error
-->" + ex.getMessage());
return null;
}
}
public static void close(Connection con) {
try {
con.close();
}
catch(Exception ex) {
}
}
}
TableDAO.java

package dao;
import beans.Question;
import beans.Topic;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
public class TopicDAO {
public static ArrayList<Topic> getTopics() {
try {
Connection con = Database.getConnection();
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("select * from
topics order by topictitle");
ArrayList<Topic> al = new ArrayList<Topic>();
while (rs.next()) {
al.add( new Topic(rs.getString("topicid"),
rs.getString("topictitle")));
}
rs.close();
return al;
} catch (Exception e) {
System.out.println("Error In TopicDAO.getTopics() -
->" + e.getMessage());
return (null);
}
}

public static ArrayList<Question> getQuestions(String


topicid) {
try {
Connection con = Database.getConnection();
PreparedStatement ps = con.prepareStatement("select
* from questions where topicid = ? order by questionid");
ps.setString(1, topicid);
ResultSet rs = ps.executeQuery();

ArrayList<Question> al = new
ArrayList<Question>();
while (rs.next()) {
al.add(new Question(rs.getString("questionid"),
rs.getString("questiontext"), rs.getString("opt1"),
rs.getString("opt2"), rs.getString("opt3")));
}
rs.close();
return al;
} catch (Exception e) {
System.out.println("Error In
TopicDAO.getQuestions() -->" + e.getMessage());
return (null);
}
}

public static boolean storeSurveyResults(String topicid,


ArrayList<Question> questions) {
Connection con = null;
PreparedStatement ps = null;
try {
con = Database.getConnection();
con.setAutoCommit(false);
ps = con.prepareStatement("insert into
answers_master values(
surveyid_sequence.nextval,?,sysdate)");
ps.setString(1, topicid);
ps.executeUpdate();

ps = con.prepareStatement("insert into
answers_details values( surveyid_sequence.currval,
?,?)");

for( Question q : questions) {


ps.setString(1, q.getId());
ps.setString(2, q.getAnswer());
ps.executeUpdate();
}
con.commit();
return true;
} catch (Exception ex) {
System.out.println("Error in
TopicDAO.storeSurveyResults() -->" +
ex.getMessage());
try {
con.rollback();
} catch (Exception nex) {
}
return false;
} finally {
Database.close(con);
}
}
}

SCREEN SHOT

You might also like