Lab 4-1-3 - JDBC Lab Part 3 - Prepared Statements
Objective
Write a class to insert a new employee into the Employees table using Prepared Statements.
Tip
- Use the command
$ ant build_jdbc_lab
to compile and build the class. - Use the script
$ ./runPreparedStatement.sh _first_name, last_name, ssn, dept, room, phone_
to run the class. You will need to create the script for this lab. - The parameters first_name, last_name, ssn, dept, room, phone are placeholders for what you want to insert into the database.
Instructions
-
Review the learning resources about Prepared Statements.
-
Create a new class,
JDBCPreparedStatement.java
. -
Using the class from the previous lab as a starting point, use the PrepareStatement class to insert a new employee.
-
Create a new script,
runPreparedStatement.sh
, to run JDBCPreparedStatement. UserunJDBClab.sh
andrunAnalyzer.sh
as models. Remember: the script will need to accept parameters for the employee values: first name, last name, ssn, dept, room, and phone.
Screenshots
To receive credit for this lab save a screenshot in the projects/screenshots/week12
directory.
You may combine the below into one screenshot and name it lab1-3.png
.
lab1-prepared-script.png
: The command line output showing the results from running therunPreparedStatement.sh
script.lab1-prepared-success.png
: The database showing that the new record was inserted.
Submit Weekly Labs
- Add, commit, and push!
- Verify all work, including screenshots are visible in GitHub.
- Create a new issue in GitHub: "Week 12 ready for review".
-
Copy the below text and paste it into the "Add a description" textarea. Answer the reflection questions in the space provided.
@kkschumacher #### How are you doing? **Are you encountering any issues preventing you from completing this week's assignments? What can I do to better support you this week?** #### What did you find particularly enlightening this week? #### What challenges (if any) did you encounter in your learning this week? #### What questions (if any) do you have about the material covered this week?
-
Click "Submit new issue"
Rubric
All of the following must be satisfied to achieve a "Met" status
- Screenshot clearly shows the results from executing
runPreparedStatement.sh
. - Screenshot clearly shows the record was added into the database.
- Code and screenshots are properly named and saved in the correct directory.
- All lab steps have been accurately and appropriately implemented.
- Code adheres to the course coding standards.
- Commit messages are concise, atomic, and effectively describe the change(s) made.
- JavaDoc documentation is properly implemented, providing clarity and understanding of the code's functionality and usage.
- External sources (websites, classmates, AI tools, etc), if utilized, are referenced and documented within the code as comments.
Additional Considerations
- Issue created correctly with thoughtful answers to the reflection questions.
- Large method have been refactored into smaller single-purpose methods.