BIG JAVA: LATE OBJECTS
2nd Edition
ISBN: 9781119626220
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Question
Chapter 23, Problem 1PE
Program Plan Intro
Program plan:
CoinDataBase.java
- Import required packages.
- Create a class named “CoinDataBase”.
- Create function “main()”.
- Check whether the length of command line argument is zero or not using “if” condition.
- If the condition is true, then print the message that there is no command line argument.
- End the program.
- Make a call to the “init” function of “BasicDataSource” class to initialize the connection.
- Use “try” block to create “Connection” and “Statement” objects.
- Create a table named “Coin” using SQL statements.
- Insert corresponding values into the table.
- Use “try” block to create “ResultSet” object.
- Compute and display the sum of values stored in the field “Value”.
- Close “result”.
-
- Close “stat”.
- Close “conn”.
- Check whether the length of command line argument is zero or not using “if” condition.
- Create function “main()”.
BasicDataSource.java:
- Import required packages.
- Create a class named “BasicDataSource”.
- Create a function named “init()”.
- Create objects for “Properties” and “FileInputStream”.
- Load the file.
- Assign values for “driver”, “url”, “username”, and “password”.
- Check whether the “username” and “password” are “null” or not.
- Load the driver by checking whether the “driver” is not “null”.
- Create a function named “getConnection()”.
- Make a call to the “getConnection()” function of “DriverManager” class by passing the arguments “url”, “username”, and “password” to establish the connection and return to the called function.
- Create a function named “init()”.
Expert Solution & Answer
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Chapter 23 Solutions
BIG JAVA: LATE OBJECTS
Ch. 23.1 - Prob. 1SCCh. 23.1 - Prob. 2SCCh. 23.2 - Prob. 3SCCh. 23.2 - Prob. 4SCCh. 23.3 - Prob. 5SCCh. 23.3 - Prob. 6SCCh. 23.4 - Prob. 7SCCh. 23.4 - Prob. 8SCCh. 23.5 - Prob. 9SCCh. 23.5 - Prob. 10SC
Ch. 23.5 - Prob. 11SCCh. 23.5 - Prob. 12SCCh. 23 - Prob. 1RECh. 23 - Prob. 2RECh. 23 - Prob. 3RECh. 23 - Prob. 4RECh. 23 - Prob. 5RECh. 23 - Prob. 6RECh. 23 - Prob. 7RECh. 23 - Prob. 8RECh. 23 - Prob. 9RECh. 23 - Prob. 10RECh. 23 - Prob. 11RECh. 23 - Prob. 12RECh. 23 - Prob. 13RECh. 23 - Prob. 14RECh. 23 - Prob. 15RECh. 23 - Prob. 16RECh. 23 - Prob. 17RECh. 23 - Prob. 18RECh. 23 - Prob. 19RECh. 23 - Prob. 20RECh. 23 - Prob. 21RECh. 23 - Prob. 22RECh. 23 - Prob. 23RECh. 23 - Prob. 1PECh. 23 - Prob. 2PECh. 23 - Prob. 5PECh. 23 - Prob. 6PE