Zoo tutorials: [ SQL | Linux | XML ]
ProgZoo: [ Java | C# | VB | C++ | Perl ]
Log in

A Gentle Introduction to
C++ Programming

Tutorial: Changing a table using parameters

 

You create a PreparedStatement with an SQL statement that includes question marks. You can set the value of these parameters then execute the statement.

PreparedStatement ps = c.prepareStatement("DELETE FROM mega WHERE name=?");
ps.setString(1,"United Kingdom");
ps.execute();

For extra points use addBatch() and executeBatch(). See INSERT a batch for an example.

1. Using INSERT .. VALUE


Big

In this program a temporary table mega is created. You must write the routine changeMega that adds a row to the table.

Add the new country 'Neverland' with a population of 10.

2. Gotta go


Big

Delete the countries that have been condemned.

3. Updating values


Big

The String pops includes changes to be made to the table mega.

You will need to build and execute update statements such as:

UPDATE mega
 SET population=9200000
 WHERE name='Bolivia'

Update the table according to details given. Also, remove the println statements.