Dreamweaver

Use JSP prepared statements to modify a database

You can use Dreamweaver to create JSP prepared statements that insert, update, or delete records in a database. A JSP prepared statement is a reusable server object that contains a SQL statement. You supply the prepared statement with the SQL that performs the operation on the database.

  1. In Dreamweaver, open the JSP page that will run the command.
  2. Open the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button and select Prepared (Insert, Update, Delete).

    The Prepared (Insert, Update, Delete) dialog box appears.

  3. Enter a name for the prepared statement, select a connection to the database containing the records you want to edit, and select the editing operation you want the prepared statement to perform—Insert, Update, or Delete.

    Dreamweaver starts the SQL statement for you based on the type of operation you select.

  4. Complete the SQL statement.

    For information on writing SQL statements that modify databases, consult a Transact‑SQL manual.

  5. Use the Variables area to define any SQL variables.

    In the Param column, enter the name of the SQL parameters used in the SQL statement. In the Run-Time Value column, enter the form or URL parameter supplying a value to each SQL parameter. For example, if the value to be assigned to a SQL parameter is supplied by a URL parameter called txtCity, enter the following run-time value:

    request.getParameter(“txtCity”)
  6. Click OK.

    After you close the dialog box, the JSP code is inserted in your page; when the code runs on the server, it creates a prepared statement that inserts, updates, or deletes records in the database.