726N/A/*
726N/A * CDDL HEADER START
726N/A *
726N/A * The contents of this file are subject to the terms of the
726N/A * Common Development and Distribution License (the "License").
726N/A * You may not use this file except in compliance with the License.
726N/A *
726N/A * See LICENSE.txt included in this distribution for the specific
726N/A * language governing permissions and limitations under the License.
726N/A *
726N/A * When distributing Covered Code, include this CDDL HEADER in each
726N/A * file and include the License file at LICENSE.txt.
726N/A * If applicable, add the following below this CDDL HEADER, with the
726N/A * fields enclosed by brackets "[]" replaced with your own identifying
726N/A * information: Portions Copyright [yyyy] [name of copyright owner]
726N/A *
726N/A * CDDL HEADER END
726N/A */
726N/A
726N/A/*
726N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
726N/A * Use is subject to license terms.
726N/A */
726N/A
726N/Apackage org.opensolaris.opengrok.jdbc;
726N/A
726N/Aimport java.sql.Connection;
726N/Aimport java.sql.PreparedStatement;
726N/Aimport java.sql.SQLException;
726N/Aimport java.sql.Statement;
726N/A
726N/A/**
726N/A * A {@code StatementCreator} class that creates insert statements which
726N/A * return generated keys.
726N/A */
726N/Apublic final class InsertQuery extends StatementCreator {
726N/A
726N/A /** The SQL text for the query. */
726N/A private final String sql;
726N/A
726N/A /**
726N/A * Create an {@code InsertQuery} instance.
726N/A * @param sql the SQL text
726N/A */
726N/A public InsertQuery(String sql) {
726N/A this.sql = sql;
726N/A }
726N/A
726N/A /**
726N/A * Create a prepared statement with {@code RETURN_GENERATED_KEYS}.
726N/A */
726N/A @Override
726N/A PreparedStatement create(Connection conn) throws SQLException {
726N/A return conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
726N/A }
726N/A}