Here you can find the source of createPreparedStatement(Connection conn, String sql, String[] args)
private static PreparedStatement createPreparedStatement(Connection conn, String sql, String[] args) throws SQLException
//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; } }