Question: Descripton: In this homework, you will be working with a database named cst 4 6 7 using Java and JDBC ( Java Database

Descripton:
In this homework, you will be working with a database named "cst467" using Java and JDBC (Java
Database ConnecKvity). The database consists of three tables related to employee informaKon. Your task
is to write Java code to perform various queries on these tables.
Instruc)ons:
1. Create a Java applicaKon project at NetBeans following the naming convenKon: hw1-lastname
E.g. hw1-kucuk
2. Assume there exists a user cst467 on localhost and a MySQL database cst467 on my end. I will
test your script connecKng on this database. You may create a dummy database on your end
following the schema below. You may populate and insert data as much as you want to the tables
paying aZenKon to the constraints to test your script.
3. Download UKls.java class and import it in your project. Do not forget to change the package name.
4. You will write scripts inside the predefined methods answering the quesKons below.
5. Refer to the Main method in the Hw1Kucuk.java file. That is how you and I run the program with
the methods defined in the UKls class.
6. The program should not break at any Kme. If an error occurs, the error message should be displayed.
7. Aaer compleKng the assignment, zip the project directory (hw1-kucuk.zip) and submit it in
Blackboard.
Ques)ons
(10) Task 1. Create and iniKalize JDBC URL, username and password variables. Make sure that the
variables cannot be updated from the other class.
(15) Task2. Retrieve and display all records from the employees table in the following format.
Employee ID: , Name: , Department ID: , Hire Date:
(15) Task3. Display the names and department names of employees in the following format.
Name: , Department:
(10) Task4. Find and display the highest salary in the following format.
Highest Salary: $
(15) Task5. Retrieve and display employees hired in 2023 in the following format.
Name: , Department: , Hire Date:
(15) Task6. Update the salary of an employee with a given employee id. If the transacKon is successful,
display the informaKon:
Salary updated successfully for Employee ID:
If the transacKon is not successful, display:
Employee not found with ID:
(10) Task7. Update the salary of an employee with the employees full name. If the transacKon is
successful, display the informaKon:
Salary updated successfully.
If the transacKon is not successful, display:
Employee not found.
(10) Task8. Delete the employees who were hired before a date. Display the number of employees
deleted.
employee(s) deleted
//change the package name!
// e.g. package com.mycompany.hw1.
package com.mycompany.hw1.kucuk;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Utils {
// Task 1: Create and init JDBC URL, username, and password of MySQL server
// Task 2: Retrieve and display all records from the "employees" table
public void displayEmployees(Connection conn){
}
// Task 3: Display names and department names of employees
public void displayEmployeeNamesAndDepartments(Connection conn){
}
// Task 4: Find and display the highest salary
public void displayHighestSalary(Connection conn){
}
// Task 5: Retrieve employees hired since 2023
public void displayEmployeesHiredin2023(Connection conn){
}
// Task 6: Update the salary of an employee by ID
public void updateEmployeeSalary(Connection conn, int employeeId, double newSalary){
}
// Task 7: Update the salary of an employee by Name
public void updateEmployeeSalaryByName(Connection conn, String employeeFullName, double newSalary){
}
// Task 8: Delete employees hired before a date.
public void deleteEmployeesBeforeTheDate(Connection conn, String hiredate){
}
}
//copy and paste the main method and libraries to your project for testing
//pay attention to the package and class names
package com.mycompany.hw1.kucuk;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Hw1Kucuk {
public static void main(String[] args){
try {
//Load the driver
Class.forName("com.mysql.cj.jdbc.Driver");
Utils myUtil = new Utils();
//Connect to the database
Connection conn;
conn = DriverManager.getConnection(myUtil.getURL(), myUtil.getUSER(), myUtil.getPASSWORD());
System.out.println("Connection Successful!");
System.out.println("
TASK2
-------
Employees Table:");
myUtil.displayEmployees(conn);
System.out.println("
TASK3
-------
Employee Names and Department Names:");
myUtil.displayEmployeeNamesAndDepartments(conn);
System.ou
 Descripton: In this homework, you will be working with a database

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!