For the code snippet listed below fill in the code snippet b
For the code snippet listed below, fill in the code snippet based on the following information.
We have a customer table that has the following fields, where we assume that there is a customer with a CustomerNumber value of 10.
CustomerNumber Integer
CustomerName Varchar
Also, use the following string information.
String dataBaseURL = \"jdbc:mysql://localhost:3306/Customer;
String userName = \"Rich\";
String passWord =\"zebra\";
You will need to build a SELECT STATEMENT that searches for the CustomerName based on the CustomerNumber field having a value of 10.
try
{
String dataBaseURL = \"\";
String userName = \"\";
String passWord =\"\";
Connection connection = DriverManager.getConnection( , ,);
Statement statement= connnection.createStatement();
ResultSet rs = statement.executeQuery(\"\");
System.out.println(rs.getString(\"\"));
}
catch (SQLException e)
{
e.printStackTrace();
}
Solution
try
{
String dataBaseURL = \"jdbc:mysql://localhost:3306/Customer\";
String userName = \"Rich\";
String passWord =\"zebra\";
Connection connection = DriverManager.getConnection(dataBaseURL,userName,passWord);
Statement statement= connnection.createStatement();
ResultSet rs = statement.executeQuery(\"select CustomerName from Customer where CustomerNumber=10);
System.out.println(rs.getString(1));
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
connection.close();
statement.close();
rs.close();
}

