Question & Answer: Which statement will set the value John to the first parameter of the P…..

Java

Question 6

Which statement will set the value John to the first parameter of the PreparedStatement below?
String sql = “insert into Student (first, middle, last) values (?, ?, ?)” ;
PreparedStatement ps = conn.prepareStaement(sql);

ps.setString(0, “John”);
ps.setString(0, ‘John’);
ps.setString(1, “John”);
ps.setString(1, ‘John’);

Question 7

Which statement is used to execute the query “Select * from products” using the Statement object stmt?

stmt.executeUpdate(“Select * from products”);
stmt.exectue(“Select * from products”);
stmt.exectueQuery(“Select * from products”);
stmt.query(“Select * from products”);

Question 8

What statement needs to be included below to retrieve all rows from the Invoices table with InvoiceTotal greater than 100?
String sql = “SELECT InvoiceDate, InvoiceTotal ”
+ “FROM Invoices WHERE InvoiceTotal > ?”;
PreparedStatement ps = connection.prepareStatement(sql);
//what goes here
ResultSet invoices = ps.executeQuery();

ps.setValue(0, 100);
ps.setValue(1, 100);
ps.setDouble(0, 100);
ps.setDouble(1, 100);

Question 9

What must you make available to your application before you can use JDBC to connect to a database?

A database driver
A web server
A firewall
An ODBC data source

Question 10

A _____ is a swing GUI component that can be bound to a database to display the results of a query.

TableModel
JTextField
JTable
JQuery

Expert Answer

 

Still stressed from student homework?
Get quality assistance from academic writers!