Online Survey System In Java

by | Feb 26, 2023 | Basic Coding, Coding, Java

Introduction of the Project

In this Java project, we will learn about how to build an online survey system in Java that creates a survey system for organizations to get feedback. In today’s digital age, businesses and organizations rely heavily on data to make informed decisions. One of the best ways to collect data is through online surveys. However, creating an online survey system can be a daunting task, especially if you’re not a skilled programmer.

Fortunately, with the power of Java, you can easily build an online survey system that meets your specific needs. In this project guide, we’ll walk you through the process of building an online survey system in Java from start to finish. So whether you’re a business owner looking to collect customer feedback or a researcher conducting a survey, this guide is for you!

To make the java project more user interactive, we will use the Swing module to create the GUI and the SQL database to store information such as Person’s name, Star Rating & Feedback.


1. To implement the slider that manages the rating & add the functionality to store that rating in database.

2. Efficient data collection: An online survey system can help you collect data more efficiently than traditional methods, as participants can complete the survey from anywhere, at any time.

3. Data analysis: An online survey system can provide you with valuable data that can be used to make informed decisions. By using Java to build your survey system, you can also build features that allow you to analyze the data easily.

4. Enhance programming skills: Building an online survey system in Java requires programming skills, which can be an excellent opportunity for students to practice and enhance their coding skills.


Before you start building an online survey system in Java, there are some prerequisites that you should be familiar with. Here are some of the essential prerequisites:

1. Java programming language: You should have a solid understanding of Java programming language, including object-oriented programming, loops, and conditional statements.

2. Java Development Kit (JDK): You need to install JDK, which includes Java Runtime Environment (JRE) and development tools, such as the Java compiler, Java debugger, and Java documentation.

3. Integrated Development Environment (IDE): An IDE is a software application that provides a comprehensive environment to develop and test Java applications. You can choose from various IDEs, such as Eclipse, NetBeans, or IntelliJ IDEA.

4. Database management: An online survey system requires a database to store and manage the survey data. You should have knowledge of database management systems, such as MySQL, PostgreSQL, or Oracle.

5. Swing module to build the Graphical User Interface

6. Web development technologies: You should be familiar with web development technologies, such as HTML, CSS, and JavaScript. This will help you create a user-friendly and responsive user interface for your online survey system.

7. Server-side programming: You should also have a good understanding of server-side programming, such as servlets, JavaServer Pages (JSP), or Spring MVC, to develop a robust and scalable online survey system.

Source Code

public class Main {
public static void main(String[] args) {
new Rating();

import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Rating {
JFrame rating = new JFrame();
private JPanel ratingPanel;
private JSlider slider1;
private JTextField textField1;
private JTextArea textArea1;
private JButton SUBMITButton;
private JLabel rate;
public Rating() {
SUBMITButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (textField1.getText().equals("") || textArea1.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Please Fill NAME and Feedback to submit.");
} else {
try {
String sql = "insert into rate" + "(Name,Rating,Feedback)" + "values (?,?,?)";
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/intern", "root", "root");
PreparedStatement statement = connection.prepareStatement(sql);
statement.setString(1, textField1.getText());
statement.setString(2, String.valueOf(slider1.getValue()));
statement.setString(3, textArea1.getText());
JOptionPane.showMessageDialog(null, "RATED SUCCESSFULLY");
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
slider1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
rate.setText(String.valueOf(slider1.getValue())+" Star");

Explanation of the Code

The two major tasks that were to be performed were One involves creating the GUI, and the other is the retrieval of information from the SQL database & updating according to the user’s input. Let us look at the GUI first:

1. Our GUI consists of a textfield, a JSlider, & a JTextArea

2. We have also provided a “Submit” button.

Moving to the retrieval, we will apply the following:

1. Firstly, we will build a connection with database using Connection object.

2. Then we Inject the query that manipulates database & add the desired data.

3. After that, we have set the minimum & maximum value of slider & specify the major tick spacing.

4. Use getValue() method to extract its value and store it in database.


Main Interface

Online Survey System in Java

We have successfully built an Online Survey System In Java that helps to rate & give feedback on the services provided. This is a very efficient way to get feedback for the services & make valuable decisions for business growth.


More Java Projects>>>

You May Also Like To Create…

Mini Radar With Arduino

Mini Radar With Arduino

Introduction of the Project Are you fascinated by radar technology and want to build your own...


Submit a Comment

Your email address will not be published. Required fields are marked *