Java SQL PreparedStatement fillInClause(PreparedStatement ps, int startIndex, Collection clauses, int sqlType)

Here you can find the source of fillInClause(PreparedStatement ps, int startIndex, Collection clauses, int sqlType)

Description

fill In Clause

License

Open Source License

Declaration

public static void fillInClause(PreparedStatement ps, int startIndex, Collection<?> clauses, int sqlType)
            throws SQLException 

Method Source Code


//package com.java2s;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static void fillInClause(PreparedStatement ps, int startIndex, Collection<?> clauses, int sqlType)
            throws SQLException {
        fillInClause(ps, startIndex, clauses.size(), clauses.iterator(), sqlType);
    }/* w  w  w . ja  va 2 s  . c o  m*/

    public static void fillInClause(PreparedStatement ps, int startIndex, int maxSize, Iterator<?> clauses,
            int sqlType) throws SQLException {
        int counter = 0;
        for (; clauses.hasNext(); ++counter) {
            ps.setObject(startIndex++, clauses.next(), sqlType);
            if (counter >= maxSize)
                break;
        }
        for (int ii = maxSize; ii > counter; ii--)
            ps.setNull(startIndex++, sqlType);
    }
}

Related

  1. createInsertPrepareStatement(Connection conn, String tableName, String[] dataColumnNames)
  2. createPreparedStatement(Connection conn, String sql, String[] args)
  3. createProjectInfo(PreparedStatement ps, long projectId, long projectInfoTypeId, String value, long modUserId)
  4. deleteOldData(Connection connection, PreparedStatement stmt, String funcId)
  5. fillArgs(Object[][] args, PreparedStatement pstmt, int i)
  6. fillParameters(PreparedStatement stmt, List params)
  7. fillPreparedStatementParams(PreparedStatement ps, Object... obj)
  8. fillStatement(PreparedStatement ps,Object...params)
  9. fillStatement(PreparedStatement stmt, Object[] params)

  10. HOME | Copyright © www.java2s.com 2016