Here you can find the source of executeUpdatePreparedStm(Connection conn, String preparedStm, Object... sqlParameters)
Parameter | Description |
---|---|
conn | : the connection that the prepared statment will exceute in |
preparedStm | : prepared statment query e.g.: select * from tbl where col1= ?... |
sqlParameters | : list filled with the prepared statment parameters |
public static int executeUpdatePreparedStm(Connection conn, String preparedStm, Object... sqlParameters) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.*; public class Main { /** execute prepared sql statment *@param conn : the connection that the prepared statment will exceute in *@param preparedStm : prepared statment query e.g.: select * from tbl where col1= ?... *@param sqlParameters : list filled with the prepared statment parameters *@return : int with number of updated rows *//*w w w. j a v a2 s . c om*/ public static int executeUpdatePreparedStm(Connection conn, String preparedStm, Object... sqlParameters) throws SQLException { //setNullableParameters(sqlParameters); int rs = 0; PreparedStatement prepStm = null; if (conn != null) { prepStm = conn.prepareStatement(preparedStm); if (sqlParameters != null) { for (int i = 1; i <= sqlParameters.length; i++) { prepStm.setObject(i, sqlParameters[i - 1]); } } rs = prepStm.executeUpdate(); } return rs; } }