package test;

import java.sql.*;

public class Test5 implements Test.Case
{
    private String error;
    private Exception ex;

    public boolean run() throws Exception {
        int res;
        Class.forName("org.sqlite.JDBC");
        Connection conn = DriverManager.getConnection(
            "jdbc:sqlite:build/test/test.db");

        ResultSet rs;
        PreparedStatement prepDrop = conn.prepareStatement(
            "DROP TABLE IF EXISTS Test5;");
        if (prepDrop.execute()) {
            error = "expected drop to return true";
            return false;
        }
        prepDrop.close();

        PreparedStatement prepCreate = conn.prepareStatement( 
            "CREATE TABLE Test5 (id);");
        if (prepCreate.execute()) {
            error = "expected create to return true";
            return false;
        }
        prepCreate.close();


        PreparedStatement prepInsert = conn.prepareStatement(
            "INSERT INTO Test5 VALUES (?);");
        PreparedStatement prepSelect = conn.prepareStatement(
            "SELECT id FROM Test5 WHERE id = ?;");

        prepInsert.setInt(1, 2);
        if ((res = prepInsert.executeUpdate()) != 1) {
            error = "expected result of 1 to update, got " + res;
            return false;
        }
        prepInsert.clearParameters();
        prepInsert.setInt(1, 3);
        if ((res = prepInsert.executeUpdate()) != 1) {
            error = "expected result of 1 to update, got " + res;
            return false;
        }
        prepInsert.close();

        prepSelect.setInt(1, 2);
        rs = prepSelect.executeQuery();
        if (!rs.next() || rs.getInt(1) != 2) {
            error = "expected result with id=2";
            return false;
        }
        prepSelect.clearParameters();

        prepSelect.setInt(1, 3);
        rs = prepSelect.executeQuery();
        if (!rs.next() || rs.getInt(1) != 3) {
            error = "expected result with id=3";
            return false;
        }
        prepSelect.close();

        conn.close();
        return true;
    }

    public String name() { return "BasicPreparedUpdate"; }
    public String error() { return error; }
    public Exception ex() { return ex; }
}

@@ -1268,32 +1268,554 @@
 alse;%0A        %7D%0A
+%0A        prepInsert.clearParameters();%0A        prepInsert.setString(1, %22Hello World, this is a string.%22);%0A        if ((res = prepInsert.executeUpdate()) != 1) %7B%0A            error = %22expected result of 1 to update, got %22 + res;%0A            return false;%0A        %7D%0A%0A        prepInsert.clearParameters();%0A        prepInsert.setString(1, %22Testing euro sign: %5Cu20ac%22);%0A        if ((res = prepInsert.executeUpdate()) != 1) %7B%0A            error = %22expected result of 1 to update, got %22 + res;%0A            return false;%0A        %7D%0A%0A
         prepInse

add setString() to prepared update test