Java SQL Execute executeSetArgs(PreparedStatement stmt, Object... args)

Here you can find the source of executeSetArgs(PreparedStatement stmt, Object... args)

Description

execute Set Args

License

Apache License

Declaration

public static <T> void executeSetArgs(PreparedStatement stmt, Object... args) throws SQLException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.PreparedStatement;

import java.sql.SQLException;

public class Main {
    public static <T> void executeSetArgs(PreparedStatement stmt, Object... args) throws SQLException {
        for (int i = 0; i < args.length; ++i) {
            stmt.setObject(i + 1, args[i]);
        }/*from  w  w w. j  a  va 2  s. c  om*/

        // Pad with nulls
        int n = stmt.getParameterMetaData().getParameterCount();
        //System.out.println("x = " + n);
        for (int i = args.length; i < n; ++i) {
            stmt.setObject(i + 1, null);
        }
        //System.out.println("y = " + n);
    }
}

Related

  1. executeInsert(Connection conn, String sql, boolean hasAutoGeneratedKey, Object... parameters)
  2. executeInsert(Connection conn, String targetTable, String destinationTable)
  3. executeInsertSQL(String sql)
  4. executeQueries(Connection conn, InputStream stream)
  5. executeResource(Connection con, String resource)
  6. executeShutDownForHSQL(java.sql.Connection connection)
  7. executeSP(Connection conn, String spName, Object... parameters)
  8. executeSql(Connection conn, String sql)
  9. executeSQL(Connection conn, String sql)