Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:31:31+00:00 2026-06-05T13:31:31+00:00

I am working on a personal project creating a punch clock in java. Since

  • 0

I am working on a personal project creating a punch clock in java. Since there will be several users clocking in and out I created a JTextField where users will type their ID number and when they click on the button(jButton1) the program should do two things.

  1. should go through the column of the database JDBC looking for the ID number and
  2. Once the ID number is found the program should copy the current time into the record for clock in or out, otherwise display an error message such as “ID number not found”.

This is the idea, I have learnt some things on my own and with the help of google. However, I cannot find this part, any help/direction at all is appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:31:33+00:00Added an answer on June 5, 2026 at 1:31 pm

    You should use a SwingWorker to perform the database operation. Since you are already using JDBC, use PreparedStatement and execute your query to fetch result.

    If result is found update database with current time, you can get current time in millisecond by calling System.currentTimeInMillis()

    Once your worker is done its operation, then display the appropriate message to the UI.

    1.How to use PreparedStatement

    2.A sample implementation for using SwingWorker for database operation

    Considering ID is coming from a JTextBox, use PreparedStatement like this:

    String sql = "SELECT FIRST_NAME, LAST_NAME, HOURS FROM WORKERS WHERE ID= ?";
    PreparedStatement pstmt = connection.prepareStatement(sql);
    pstml.setInt(1, 007859378);
    ResultSet rs = pstmt.executeQuery();
    
    while(rs.next()){
       //Extract values from ResultSet
    }
    

    This way you will prevent yourself from SQL Injection, also read how Prepared Statement helps against SQL Injection

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a personal project. I am creating a punch clock program
I'm working on a personal project to auto fill out the USPS Click &
I'm working on a personal project (C# / ASP.NET) that will use LINQ to
I am working on a personal project based in PHP and MySQL, and I
I am working on a personal project as a way of learning more about
I am working on a personal project where I need to manipulate values in
I am working on a personal project with F# and would like to experiment
I'm working on a personal project problem. It's a donation management model. I need
I am working on a personal project that uses a custom config file. The
I'm working a personal project that's going to include a home-screen widget updated with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.