Question: in java Q4 [15 points] Database . Using NetBeans, create a new database and call it DbFinal , and give it the username userfinal, and

in java

Q4 [15 points] Database.

  1. Using NetBeans, create a new database and call it DbFinal, and give it the username userfinal, and the password dbpassfinal.
  2. Implement a Java class called EmpDataBase, which has the following three methods:

1- public void createTable(). This method connects to the database DbFinal, and creates a new table called Employee in DbFinal. The table contains the fields:

  1. EmpId, Integer, not null, primary key.
  2. Name, VARCHAR(255)
  3. Salary, Integer
  4. Company, VARCHAR(255)

2- public void insertData(). This method connects to the database DbFinal, and inserts the following records into the Employee table:

112, Ahmed, 900, Microsoft

200, Muna, 700, IBM

422, Enas, 800, IBM

3- public void getData(). This method connects to the database DbFinal and retrieves each employee record that has the company name equal to IBM. Then, the method prints (using System.out.println) the EmpId and salary fields of each retrieved record.

Important note: Inside each of the above three methods, you must write all the necessary code to connect to the database, create and execute statements, and close the connection. You must also write the necessary try-catch blocks. In the catch blocks, call the printStackTrace() method.

4- Main method. This method creates and instantiates and object of type EmpDataBase, then calls the methods createTable(), insertData(), and getData().

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!