Java SQL PreparedStatement createPreparedStatement(Connection conn, String sql, String[] args)

Here you can find the source of createPreparedStatement(Connection conn, String sql, String[] args)

Description

create Prepared Statement

License

Open Source License

Declaration

private static PreparedStatement createPreparedStatement(Connection conn, String sql, String[] args)
            throws SQLException 

Method Source Code


//package com.java2s;
/*/*from  w ww  .ja  v  a 2  s.co m*/
 * Copyright (C) 2009 Josh Guilfoyle <jasta@devtcg.org>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

import java.sql.Connection;
import java.sql.PreparedStatement;

import java.sql.SQLException;

public class Main {
    private static PreparedStatement createPreparedStatement(Connection conn, String sql, String[] args)
            throws SQLException {
        PreparedStatement stmt = conn.prepareStatement(sql);

        int n = args.length;
        for (int i = 0; i < n; i++)
            stmt.setString(i + 1, args[i]);

        return stmt;
    }
}

Related

  1. closeSilentlyPreparedStatement(PreparedStatement stmt)
  2. closeStatement(PreparedStatement preparedStatement)
  3. closeStatement(PreparedStatement ps)
  4. closeStatement(PreparedStatement theStatement)
  5. createInsertPrepareStatement(Connection conn, String tableName, String[] dataColumnNames)
  6. createProjectInfo(PreparedStatement ps, long projectId, long projectInfoTypeId, String value, long modUserId)
  7. deleteOldData(Connection connection, PreparedStatement stmt, String funcId)
  8. fillArgs(Object[][] args, PreparedStatement pstmt, int i)
  9. fillInClause(PreparedStatement ps, int startIndex, Collection clauses, int sqlType)