Java SQL PreparedStatement fillStatement(PreparedStatement ps,Object...params)

Here you can find the source of fillStatement(PreparedStatement ps,Object...params)

Description

Fill a raw PreparedStatement to make it executable.

License

Apache License

Parameter

Parameter Description
ps a parameter
params a parameter

Declaration

public static PreparedStatement fillStatement(PreparedStatement ps,Object...params)

Method Source Code

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

import java.sql.PreparedStatement;

import java.sql.SQLException;

import java.util.List;

public class Main {
    /**//from w  ww. j a v  a  2s  .  c  o m
    * Fill a raw PreparedStatement to make it executable.
    * @param ps
    * @param params
    * @return
    */
    public static PreparedStatement fillStatement(PreparedStatement ps, Object... params) {
        try {
            for (int i = 0; i < params.length; i++) {
                ps.setObject(i + 1, params[i]);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return ps;
    }

    /**
    * Fill a raw PreparedStatement to make it executable.
    * @param ps
    * @param params
    * @return
    */
    public static PreparedStatement fillStatement(PreparedStatement ps, List<Object> params) {
        return fillStatement(ps, params.toArray());
    }
}

Related

  1. deleteOldData(Connection connection, PreparedStatement stmt, String funcId)
  2. fillArgs(Object[][] args, PreparedStatement pstmt, int i)
  3. fillInClause(PreparedStatement ps, int startIndex, Collection clauses, int sqlType)
  4. fillParameters(PreparedStatement stmt, List params)
  5. fillPreparedStatementParams(PreparedStatement ps, Object... obj)
  6. fillStatement(PreparedStatement stmt, Object[] params)
  7. getFileContent(final File file)
  8. getGeneratedKey(PreparedStatement ps)
  9. getGenerateKey(PreparedStatement stmt)

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