Set the given parameter values in the given PreparedStatement. - Java java.sql

Java examples for java.sql:PreparedStatement

Description

Set the given parameter values in the given PreparedStatement.

Demo Code


//package com.java2s;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Main {
    /**//from w w w  .  j a va2  s .c  o  m
     * Set the given parameter values in the given PreparedStatement.
     * @param statement The PreparedStatement to set the given parameter values in.
     * @param values The parameter values to be set in the created PreparedStatement.
     * @throws SQLException If something fails during setting the PreparedStatement values.
     */
    public static void setValues(PreparedStatement statement,
            Object... values) throws SQLException {
        for (int i = 0; i < values.length; i++) {
            statement.setObject(i + 1, values[i]);
        }
    }
}

Related Tutorials