Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello ,
I am working in a project of employees Attendance in Java ( NetBeans ) , I have created two tables, one for employee's data and the other to check the attendance.
Now I want to link the primary key of the first table to the second table but I do not know how . for example if you want to check the attendance it will show you the ID of the employee and when ( time in / time out )
could you help me, please?
Thank you

What I have tried:

this is the first table
create table employee(empID int primary key 
auto_increment , fName varchar(100),
civilId int ,mobile int );

the second table
create table  employeeAttendance   (
id int primary key auto_increment ,
empID int not null,timeIn time  ,timeOut time  ,
daay date,

constraint emp_fk foreign key (empID) references employee(empID)
);

and in Java I did that but could not complete it :
String sql="insert into employeeAttendance(empID,timeIn,daay)values(?,?,?)";
                pstmt = conn.prepareStatement(sql);
             
           pstmt.setString(1,.getText());
               // pstmt.setString(1,jComboBox1.getSelectedItem().toString());
                pstmt.setString(2,timeLabel.getText());
                 pstmt.setString(3,dateLabel.getText());
Posted
Updated 1-May-18 21:22pm
v2
Comments
wseng 2-May-18 3:21am    
what errors you get ?
CHill60 2-May-18 8:04am    
Are you trying to insert values into employeeAttendance before you have inserted the employee into the employee table? If so then you need to make sure the employee exists on the employee table before attempting to insert into employeeAttendance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900