Uploaded September 2016 | Updated November 2026, 3 hours ago
In this tutorial you will learn how to insert data into a database using java.
Project Scope
This is an introduction of a simple Java Employee Payroll Management System (Payroll System) using SQLITE database that was developed using Java Netbeans. Furthermore the use of GUI components to achieve this project are as follows:
JButton,JTable,IText,JComboBox, JLabel,JRadioButton, JFrame,JPanel,Image Icons, JTextField.
Functions used
Add Record
Deleted Record
Update Record
Clear Fields
Login
Logout
Date & Time
PDF
Objective of Java Payroll Project Employee Management System.
The main objective of the Java Project on Payroll Management System is to manage the details of Employees, Payments, Salary. It also manages all information about the Employee, Payroll and Salary Slips. The project is totally built at administrator end of things. Only the administrator is guaranteed the access. The purpose of the project is to build an application that reduces the manual work and it can be used as a school project.
Code & Imports
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.imageio.ImageIO;
import javax.swing.*;
Connection conn=null;
ResultSet rs=null;
PreparedStatement pst=null;
conn=db.java_db();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2,
size.height/2 - getHeight()/2);
try {
String sql ="insert into Staff_information "
+ "(first_name,surname,Dob,Email,"
+ "Telephone,Address,Department,"
+ "Image,Salary,Gender,Address2,"
+ "Post_code, Designation,Status,job_title,Apartment,Date_hired) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
pst=conn.prepareStatement(sql);
pst.setString(1,txt_firstname.getText());
pst.setString(2,txt_surname.getText());
pst.setString(3,txt_dob.getText());
pst.setString(4,txt_email.getText());
pst.setString(5,txt_tel.getText());
pst.setString(6,txt_address.getText());
pst.setString(7,txt_dep.getText());
pst.setString(9,txt_salary.getText());
pst.setString(10, gender);
pst.setString(11,txt_add2.getText());
pst.setString(12,txt_pc.getText());
pst.setString(13,txt_design.getText());
pst.setString(14,txt_status.getText());
pst.setString(15,txt_job.getText());
pst.setString(16,txt_apt.getText());
pst.setString(17,txt_doj.getText());
pst.execute();
JOptionPane.showMessageDialog(null,"Data is saved successfully");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
finally {
try{
rs.close();
pst.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}
CREATE TABLE "Staff_information" ("id" INTEGER PRIMARY KEY NOT NULL ,"first_name" VARCHAR,"surname" VARCHAR,"Dob" INTEGER DEFAULT (null) ,"Email" VARCHAR,"Telephone" VARCHAR,"Address" VARCHAR,"Department" VARCHAR,"Image" BLOB,"Gender" CHAR,"Salary" VARCHAR,"Address2" VARCHAR,"Apartment" VARCHAR,"Post_code" VARCHAR DEFAULT (null) ,"Designation" VARCHAR,"Status" VARCHAR,"Date_hired" VARCHAR,"job_title" VARCHAR)
Download Files here: dropbox.com/s/ps6zvfz158yqtvp/Employee%20Payroll.rar?dl=0
#java tutorial for beginners
#java tutorial
Thanks for watching.
In this tutorial you will learn how to insert data into a database using java.
Project Scope
This is an introduction of a simple Java Employee Payroll Management System (Payroll System) using SQLITE database that was developed using Java Netbeans. Furthermore the use of GUI components to achieve this project are as follows:
JButton,JTable,IText,JComboBox, JLabel,JRadioButton, JFrame,JPanel,Image Icons, JTextField.
Functions used
Add Record
Deleted Record
Update Record
Clear Fields
Login
Logout
Date & Time
Objective of Java Payroll Project Employee Management System.
The main objective of the Java Project on Payroll Management System is to manage the details of Employees, Payments, Salary. It also manages all information about the Employee, Payroll and Salary Slips. The project is totally built at administrator end of things. Only the administrator is guaranteed the access. The purpose of the project is to build an application that reduces the manual work and it can be used as a school project.
Code & Imports
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.imageio.ImageIO;
import javax.swing.*;
Connection conn=null;
ResultSet rs=null;
PreparedStatement pst=null;
conn=db.java_db();
Toolkit toolkit = getToolkit();
Dimension size = toolkit.getScreenSize();
setLocation(size.width/2 - getWidth()/2,
size.height/2 - getHeight()/2);
try {
String sql ="insert into Staff_information "
+ "(first_name,surname,Dob,Email,"
+ "Telephone,Address,Department,"
+ "Image,Salary,Gender,Address2,"
+ "Post_code, Designation,Status,job_title,Apartment,Date_hired) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
pst=conn.prepareStatement(sql);
pst.setString(1,txt_firstname.getText());
pst.setString(2,txt_surname.getText());
pst.setString(3,txt_dob.getText());
pst.setString(4,txt_email.getText());
pst.setString(5,txt_tel.getText());
pst.setString(6,txt_address.getText());
pst.setString(7,txt_dep.getText());
pst.setString(9,txt_salary.getText());
pst.setString(10, gender);
pst.setString(11,txt_add2.getText());
pst.setString(12,txt_pc.getText());
pst.setString(13,txt_design.getText());
pst.setString(14,txt_status.getText());
pst.setString(15,txt_job.getText());
pst.setString(16,txt_apt.getText());
pst.setString(17,txt_doj.getText());
pst.execute();
JOptionPane.showMessageDialog(null,"Data is saved successfully");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
finally {
try{
rs.close();
pst.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}
CREATE TABLE "Staff_information" ("id" INTEGER PRIMARY KEY NOT NULL ,"first_name" VARCHAR,"surname" VARCHAR,"Dob" INTEGER DEFAULT (null) ,"Email" VARCHAR,"Telephone" VARCHAR,"Address" VARCHAR,"Department" VARCHAR,"Image" BLOB,"Gender" CHAR,"Salary" VARCHAR,"Address2" VARCHAR,"Apartment" VARCHAR,"Post_code" VARCHAR DEFAULT (null) ,"Designation" VARCHAR,"Status" VARCHAR,"Date_hired" VARCHAR,"job_title" VARCHAR)
Download Files here: dropbox.com/s/ps6zvfz158yqtvp/Employee%20Payroll.rar?dl=0
#java tutorial for beginners
#java tutorial
Thanks for watching.










