Question

In: Computer Science

Because the database server can cache and reuse ___________________ statements, they are more efficient than regular...

Because the database server can cache and reuse ___________________ statements, they are more efficient than regular SQL statements.

When you work with a result set, the ____________ identifies the current position in the result set.

You use the __________________ class to work with data returned from a SQL query.

What does the invoices result set contain after the code that follows is executed?
String sql = "SELECT InvoiceDate, InvoiceTotal "
           + "FROM Invoices WHERE InvoiceTotal > ?";
PreparedStatement ps = connection.prepareStatement(sql);
ps.setDouble(1, 100);

ResultSet invoices = ps.executeQuery();

a.

All rows from the Invoices table

b.

Rows from the Invoices table where InvoiceTotal is greater than 100

c.

Rows from the Invoices table where InvoiceTotal is greater than 0

d.

Rows from the Invoices table where InvoiceTotal is greater than 1

Solutions

Expert Solution

Answers:

Because the database server can cache and reuse Prepared Statements statements, they are more efficient than regular SQL statements.

Explanation : Prepared Statements are used for executing sql queries dynamically.They are pre-compiled SQL statements invoked with different paramters and reduce the time of SQL statement compilation.Prepared Statements are very faster as they are compiled only once.

When you work with a result set, the getRow() identifies the current position of the pointer in the result set.
We can toggle the cursors front and back using specific methods (last(),beforeFirst()) available from Result Set Object.

Explanation: Method getRow() points to current position of the cursor in Result Set. The initial position of the
cursor starts with 0.

You use the ResultSet  to work with data returned from a SQL query.

Explanation: ResultSet Java Object is used to store the results retrieved from executing queries using Statements available from JDBC. Result available in ResultSet object are retrieved one by one using next method and there are set of get methods to access colums from each rows.
----------------------------------------------------------------------------------------------------------------------------------------------------------

Solution : B. Rows from the Invoices table where InvoiceTotal is greater than 100

Explanation :

String sql = "SELECT InvoiceDate, InvoiceTotal "
+ "FROM Invoices WHERE InvoiceTotal > ?";
PreparedStatement ps = connection.prepareStatement(sql);
// In the place of '?' parameter value 100 is passed.
ps.setDouble(1, 100);
//result is executed and results are stored here.
ResultSet invoices = ps.executeQuery();

The query returns only fields mentioned InvoiceDate and InvoiceTotal from Invoices table where the InvoiceTotal is greaterthan 100. In case if there is a alteration in Query as select * from Invoices WHERE InvoiceTotal > ?; The result will return all the column from the rows matching criteria.


Related Solutions

Pollution taxes and tradable pollution permits are more efficient forms of regulation than pollution limits because:...
Pollution taxes and tradable pollution permits are more efficient forms of regulation than pollution limits because: Taxes and tradable permits cause firms with lower abatement costs to pollute less than firms with higher abatement costs Taxes and tradable permits cause a greater reduction in pollution than pollution limits Taxes and tradable permits increase firms’ marginal costs Taxes and tradable permits reduce firms’ marginal costs Taxes and tradable permits cause firms with lower abatement costs to pollute more than firms with...
Which of the following statements about angiosperm reproduction is FALSE? Animal pollination is more efficient than...
Which of the following statements about angiosperm reproduction is FALSE? Animal pollination is more efficient than wind pollination Fruits increase the success of dispersal because animals consume the seeds can survive digestive tracts There is a diverse array of flower shapes and colors, largely related to the mode of pollination The pollen grain goes through lots of rounds of mitosis to become the fruit
How can there be more than one efficient distribution of goods? Which distribution of goods is...
How can there be more than one efficient distribution of goods? Which distribution of goods is "most efficient”?
"How can I connect my hadoop database or mysql database server to my d3 visual?"
"How can I connect my hadoop database or mysql database server to my d3 visual?"
Write a regular expression that can represent any digit, without more than one digit or non...
Write a regular expression that can represent any digit, without more than one digit or non digit characters.
A limitation of the chat server is that it can handle only one client because it...
A limitation of the chat server is that it can handle only one client because it is a single threaded application. Using the pThread library, modify the chat server so that it can handle multiple clients simultaneously, i.e., by creating a new thread whenever a client is connected so that the client is handled individually with a new thread, and at the same time, by having the main thread (i.e., the thread that runs the main function) of the chat...
Which of the following statements concerning the variance are correct? (NOTE: THERE CAN BE MORE THAN...
Which of the following statements concerning the variance are correct? (NOTE: THERE CAN BE MORE THAN ONE CORRECT ANSWER) a.The larger the variance, the greater the total risk of the investment. b.If a stock portfolio is well-diversified, then the portfolio variance may be less than the variance of the least risky stock in the portfolio. c.The larger the variance, the smaller the standard deviation. d.The larger the variance, the more the actual returns tend to differ from the average return....
FuncoLand has developed an efficient, new cloud server that that it can sell to other corporations...
FuncoLand has developed an efficient, new cloud server that that it can sell to other corporations to boost online operations and stability. For FuncoLand, it would cost $10,000,000 at Year 0 to buy the equipment necessary to manufacture the server. The project would require net working capital at the beginning of each year in an amount equal to 10% of the year’s projected sales; for example, NWC0 = 10% (Sales1). The servers would sell for $24,000 per unit, and specialists...
FuncoLand has developed an efficient, new cloud server that that it can sell to other corporations...
FuncoLand has developed an efficient, new cloud server that that it can sell to other corporations to boost online operations and stability. For FuncoLand, it would cost $10,000,000 at Year 0 to buy the equipment necessary to manufacture the server. The project would require net working capital at the beginning of each year in an amount equal to 10% of the year’s projected sales; for example, NWC0 = 10% (Sales1). The servers would sell for $24,000 per unit, and specialists...
NO Handwriting Please ! Will there be anything more efficient and better than LEDs? If so,...
NO Handwriting Please ! Will there be anything more efficient and better than LEDs? If so, how long will it be until that happens?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT