Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Give SCREENSHOT Fabricate an information base named your last name. Then, at that point, buid a table that contains somewhere around 3 to 4

Question: Give SCREENSHOT

Fabricate an information base named "your last name". Then, at that point, buid a table that contains somewhere around 3 to 4 fields. Utilize the Java source code ListCustomer2.java. Change the name of the data set and table in the source code. As you can find in the code my data set name was "test" and client name was "root" [for MySql] and the secret word was "understudies". You will utilize your data set name, client name and secret phrase for this activity. Test SQL order from Java program. I'm utilizing the SQL order "SELECT * from client". You can run and test any SQL order. Run and order your altered Java source code. In the lab report joined the screen shots of your work, changed Java code, illustrations learned, and so on Java source code ListCustomer2.java.

import java.sql.*;

public class ListCustomers2 { public static void main(String[] args) {

String url = "jdbc:mysql://localhost:3306/test"; String driver="com.mysql.jdbc.Driver";

listCustomers (driver, url, "root", "understudies"); }

public static void listCustomers(String driver, String url, String username, String secret phrase) { Association conn = invalid; Explanation proclamation = invalid; attempt { Class.forName(driver).newInstance();//Register the JDBC driver. Technique Two

conn = DriverManager.getConnection( url, username, secret key);

System.out.println ("Customer Table ");

explanation = conn.createStatement(); String question = "SELECT * FROM client";

ResultSet rst = statement.executeQuery(query);

ResultSetMetaData rstMetaData = rst.getMetaData();

int columnCount = rstMetaData.getColumnCount();

for (int I = 1; I < columnCount+1; i++) { System.out.print(rstMetaData.getColumnName(i) + " "); }

System.out.println();

while(rst.next()) { for (int I = 1; I < columnCount+1; i++) System.out.print(rst.getString(i) + "t"); System.out.println(""); } } get (ClassNotFoundException cnfe) { System.out.println("Error Loading Driver: " + cnfe); } get (SQLException sqle) { System.out.println("SQL Error: " + sqle); } get (Exception e) { System.out.println("Error: " + e); } at long last { attempt { if (proclamation != invalid) statement.close(); if (conn != invalid) conn.close(); } get (SQLException sqle) { sqle.printStackTrace(); } } } } // End of File

imageimage

Question 2 [50 points] A- Write a C Program that has one function and one main as described below: In the main, declare an array of ten integers. Ask the user to enter the salaries of ten employees and store them in this array. Negative numbers should not be accepted. [15 points] Write a function called Statistics that takes as arguments the array and its size, and returns the number of employees having a salary above the average salary. [20 points] In the main, call the function Statistics and print the number of salaries above the average salary. [5 points] B- If you modify one of the salaries in the array within the function Statistics, will the changes to the array be reflected in the main? Explain. [10 points]

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below For the first part of your question regarding the Java program and database interaction y... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Programming questions

Question

What is a database?

Answered: 1 week ago