Question: Give SCREENSHOT Fabricate an information base named your last name. Then, at that point, buid a
Question:
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
Concepts of Database Management
ISBN: 978-1285427102
8th edition
Authors: Philip J. Pratt, Mary Z. Last