The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
1. Programming assignment.
2. 8 question debugging exercise
Â
4 Using a Database Query Result
Write a Java program to query the StockTracker database for all users and all stocks held by each user. List the user s ID, first name, and last name followed by their stocks, including both the stock symbol and stock description (name). This can be a console application that produces output to the screen, as shownin Figure 11-80. Use the project, StockTracker, to add additional users and stocks, if necessary. For an extra challenge, use only the StockTrackerDB data access class to obtain data from the database.
Â
Figure 11-80.
Â
Â
Â
Â
Debugging Assignment
Find and fix the error in each line of code. Each line contains only one error.
Indented lines continue the previous statement.
1.forName("sun.jdbc.odbc.JdbcOdbcDriver");
2.String dbn = " AutoParts";
3.Connection con = getConnection(dbn);
4.Statement stmt = DriverManager.createStatement();
5.stmt.executeUpdate("CREATE TABLE StockItemsitemID INT "
6.+"CONSTRAINT PK_Item PRIMARY, "
7. +"CONSTRAINT FK1_Item REFERENCES PartDesc (partno) "
8.+"qtyOnHand INT, price SINGLE, cost SINGLE");
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll