What is the value of y after the following code executes:
float y = 3.4 + sqrt (25.0);
8.4
You might also like to view...
Use JSP scriptlets to create the database Connection and Statement objects for the Phone Book application. The phonebook database has the table phoneNumbers, which contains three columns—id, name and phoneNumber. The id field is a unique number to identify a person. The name field is a string that specifies the person’s name. The phoneNumber field is a string that indicates the person’s phone number.
a) Opening phoneBook.jsp. Open the phoneBook.jsp file that you created. b) Importing classes from java.sql for use in the JSP. Copy lines 4–5 of and insert them in line 4 of phoneBook.jsp. c) Adding a JSP scriptlet. Inside the select HTML element in the phoneBook.jsp source code add a JSP scriptlet that contains a try block and a catch block that catches SQLExceptions thrown from the try block. d) Adding a Connection to the database. In the try block declared in the previous step, specify the database location with value "C:\\Examples\\Tutorial31\\Exer- cises\\Databases", load the database driver class and connect to the phonebook database (jdbc:db2j:phonebook). [Note: If you copied and pasted the Tutorial31 directory on the CD to a directory other than C:\Examples, then replace C:\\Examples with the directory to where you pasted Tutorial31.] e) Creating a Statement and executing a query that retrieves names from the database. In the try block, after the database connection is created successfully, create a Statement object that will be used to execute an SQL query. Execute a query that gets all the names from the database. f) Closing the database connection. After executing the query, invoke the close method of the Connection object to disconnect from the database. g) Displaying the SQLException error message. Inside the catch block of the phone- Book.jsp, display the SQLException error message using the println method of the implicit JSP object out. h) Saving the file. Save your modified file phoneBook.jsp file. i) Opening phoneNumber.jsp. Open the phoneNumber.jsp file that you created in Exercise 30.11. j) Importing classes from java.sql for use in the JSP. Copy lines 4–5 of Fig. 31.22 and insert them in line 4 of phoneNumber.jsp. k) Starting a JSP scriptlet. In the phoneNumber.jsp source code, after the h1 HTML element, start a JSP scriptlet. Inside the scriptlet, start a try block. l) Adding a Connection to the database. In the try block, specify the database location with value "C:\\Examples\\Tutorial31\\Exercises\\Databases", load the database driver class and connect to the phonebook database. [Note: If you copied and pasted the Tutorial31 directory on the CD to a directory other than C:\Exam- ples, then replace C:\\Examples with the directory to where you pasted Tutorial31.] m)Creating a Statement object and executing a query that retrieves information from the database. After the database connection is created successfully, create a State- ment object that will be used to execute an SQL query. Execute a query that gets the information of the person whose name the user selected. n) Ending the scriptlet. Before the p (paragraph) HTML element containing “num- bers,” end the scriptlet you started in Step k so that literal HTML markup can be placed in the response to the client. o) Adding a second JSP scriptlet. In the phoneNumber.jsp source code, after the para- graph HTML element containing the hyperlink to phoneBook.jsp, add a second JSP scriptlet that will close the database connection, end the try block and display an error message if an exception occurs. p) Saving the file. Save your modified phoneNumber.jsp file. q) Copying the phoneBook.jsp and phoneNumber.jsp files to the Tomcat webapps directory. Copy your updated phoneBook.jsp and phoneNumber.jsp files and paste them into the C:\Program Files\Apache Group\Tomcat 4.1\webapps\PhoneBook directory. r) Copying the database JAR files to the Phone Book Web application. The informa- tion tier for the Phone Book Web application uses the Cloudscape database. You need to copy the db2j.jar and license.jar files to the C:\Program Files\ Apache Group\Tomcat 4.1\webapps\PhoneBook\WEB-INF\lib directory. The db2j.jar and license.jar files are located in the C:\Cloudscape_5.1\lib direc- tory. In Tutorial 26, if you installed Cloudscape in a directory other than C:\Cloudscape_5.1, replace C:\Cloudscape_5.1 with your Cloudscape installa- tion. s) Starting Tomcat. Select Start > Programs > Apache Tomcat 4.1 > Start Tomcat to start the Tomcat server. t) Testing the application. Open a Web browser and enter the URLs http:// localhost:8080/PhoneBook/phoneBook.jsp and http://localhost:8080/ PhoneBook/phoneNumber.jsp to test the application. u) Stopping Tomcat. Select Start > Programs > Apache Tomcat 4.1 > Stop Tomcat to stop the Tomcat server.
The collections framework provides various __________ collection interfaces from which the programmer can quickly "flesh out" complete customized implementations.
a. abstract. b. concrete. c. structured. d. unstructured.
A one-to-one relationship between two tables is used when data is placed in a separate table to restrict access to the information
Indicate whether the statement is true or false
To properly secure a database, ________ should be disabled because they allow users access to the Navigation Pane and the Visual Basic Editor, even if these items are hidden from view initially in the database
Fill in the blank(s) with correct word