Create a bean called JDBCQueryBean that is a modification of JDBCBean.

(i) Create a bean called JDBCQueryBean that is a modification of

 

JDBCBean. Instead of dealing only with a fixed query 'SELECT * FROM

Accounts', this bean should be capable of processing any query directed at the

Accounts/Stock table (depending upon which database you are using). The

code for the major method getQueryResults is supplied overleaf. In addition

to this method, the bean should provide read/write access to a property called

query that holds the current query (and has a default value of 'SELECT *

FROM Accounts'). Read access should also be provided to properties

numFields (holding the number of fields in the query) and numRows (the

number of rows in the query results).

(ii) Create a simple HTML page that uses a text field in a form to accept the

user's query and pass it on to a JSP called JDBCQuery.jsp.

(iii) Possibly using JDBC.jsp as a starting point, produce a JSP that accepts

the query from the above HTML page and then uses the bean to display the

results of the query in a table.

public static Vector getQueryResults()

throws SQLException

{

results = statement.executeQuery(getQuery());

metaData = results.getMetaData();

numFields = metaData.getColumnCount();

queryResults = new Vector();

fieldNames = new Vector();

dataTypes = new Vector();

for (int i=1; i<=numfields;>

fieldNames.add(metaData.getColumnName(i));

while (results.next())

{

for (int i=1; i<=numfields;>

{

int colType = metaData.getColumnType(i);

switch (colType)

{

case Types.INTEGER:

queryResults.add(results.getInt(i));

dataTypes.add(“integer”);

break;

case Types.VARCHAR:

queryResults.add(

results.getString(i));

dataTypes.add(“string”);

break;

case Types.NUMERIC:

queryResults.add(

results.getFloat(i));

dataTypes.add(“float”);

break;

default: //Hopefully, will never happen!

queryResults.add(

results.getString(i));

dataTypes.add(“string”);

}

}

}

return queryResults;

find the cost of your paper

prepare a lead container of mass 1.5 kg and pour 0.65 kg of water into it, both at the room temperature of 20.5°C.

You are at a restaurant eating lunch with a friend. After the meal, your friend realizes they left their wallet at home. Your friend gives you a piece of silver….

Given the above information, how many people did McKinsey and BCG hire in the year 2013?

There are two big consulting firms in Melbourne, McKinsey and Boston Consulting Group (BCG); assume that their clients view them as providing identical consulting services. They hire people on yearly….

write a program that reads a file and displays all of the words in it that are misspelled.

A spell checker can be a helpful tool for people who struggle to spell words correctly. In this exercise, you will write a program that reads a file and displays….