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");

    • 12 years ago
    Solution
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      stocktracker_2.zip
    • attachment
      debugging_answer.docx