List of usage examples for org.springframework.jdbc.core StatementCreatorUtils setParameterValue
public static void setParameterValue(PreparedStatement ps, int paramIndex, int sqlType, @Nullable Object inValue) throws SQLException
From source file:com.nortal.petit.core.util.ArgPreparedStatementSetter.java
public static int setValues(PreparedStatement ps, Object[] args, int startIndex) throws SQLException { int j = startIndex; if (args != null) { for (int i = 0; i < args.length; i++, j++) { Object arg = args[i]; if (arg instanceof SqlParameterValue) { SqlParameterValue paramValue = (SqlParameterValue) arg; StatementCreatorUtils.setParameterValue(ps, j, paramValue, paramValue.getValue()); } else { StatementCreatorUtils.setParameterValue(ps, j, SqlTypeValue.TYPE_UNKNOWN, arg); }// w w w. ja va2 s . co m } } return j; }
From source file:com.github.ferstl.spring.jdbc.oracle.TestParameterizedPreparedStatementSetter.java
@Override public void setValues(PreparedStatement ps, int[] argument) throws SQLException { for (int i = 0; i < argument.length; i++) { StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, argument[i]); }/*w w w . j av a 2 s .c o m*/ }
From source file:com.github.ferstl.spring.jdbc.oracle.TestBatchPreparedStatementSetter.java
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN, Integer.MAX_VALUE); StatementCreatorUtils.setParameterValue(ps, 2, SqlTypeValue.TYPE_UNKNOWN, this.parameters[i]); }
From source file:com.github.ferstl.spring.jdbc.oracle.TestInterruptiblePreparedStatementSetter.java
@Override protected boolean setValuesIfAvailable(PreparedStatement ps, int i) throws SQLException { if (i >= this.parameters.length) { return false; }/*ww w . j ava2 s . c o m*/ StatementCreatorUtils.setParameterValue(ps, 1, SqlTypeValue.TYPE_UNKNOWN, Integer.MAX_VALUE); StatementCreatorUtils.setParameterValue(ps, 2, SqlTypeValue.TYPE_UNKNOWN, this.parameters[i]); return true; }
From source file:cc.tooyoung.common.db.ArgPreparedStatementSetter.java
public void setValues(PreparedStatement ps) throws SQLException { if (this.args != null) { for (int i = 0; i < this.args.length; i++) { Object arg = this.args[i]; if (arg instanceof SqlParameterValue) { SqlParameterValue paramValue = (SqlParameterValue) arg; StatementCreatorUtils.setParameterValue(ps, i + 1, paramValue, paramValue.getValue()); } else { StatementCreatorUtils.setParameterValue(ps, i + 1, SqlTypeValue.TYPE_UNKNOWN, arg); }// w w w.java2s . c o m } } }
From source file:org.snaker.engine.spring.SpringJdbcAccess.java
public void saveProcess(final Process process) { super.saveProcess(process); if (process.getBytes() != null) { template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { try { lobCreator.setBlobAsBytes(ps, 1, process.getBytes()); StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId()); } catch (Exception e) { e.printStackTrace(); }//from www.j a v a 2 s. c o m } }); } }
From source file:org.snaker.engine.access.spring.SpringJdbcAccess.java
@Override public void saveProcess(final Process process) { super.saveProcess(process); if (process.getBytes() != null) { template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) { @Override//from w w w .j a v a 2 s. c o m protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { try { lobCreator.setBlobAsBytes(ps, 1, process.getBytes()); StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId()); } catch (Exception e) { e.printStackTrace(); } } }); } }
From source file:fr.acxio.tools.agia.item.database.ExpressionsPreparedStatementSetter.java
@Override public synchronized void setValues(PreparedStatement sPs) throws SQLException { try {/* www . j a v a 2s. c om*/ String aResolvedValue; for (int i = 0; i < lookupFieldsExpressions.length; i++) { aResolvedValue = getExpressionResolver().evaluate(lookupFieldsExpressions[i], getEvaluationContext(), String.class); StatementCreatorUtils.setParameterValue(sPs, i + 1, SqlTypeValue.TYPE_UNKNOWN, aResolvedValue); } } catch (Exception e) { throw new SQLException(new PreparedStatementCreationException(e)); } }
From source file:cc.tooyoung.common.db.ArgTypePreparedStatementSetter.java
@SuppressWarnings("unchecked") public void setValues(PreparedStatement ps) throws SQLException { int argIndx = 1; if (this.args != null) { for (int i = 0; i < this.args.length; i++) { Object arg = this.args[i]; if (arg instanceof Collection && this.argTypes[i] != Types.ARRAY) { Collection entries = (Collection) arg; for (Iterator it = entries.iterator(); it.hasNext();) { Object entry = it.next(); if (entry instanceof Object[]) { Object[] valueArray = ((Object[]) entry); for (int k = 0; k < valueArray.length; k++) { Object argValue = valueArray[k]; StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], argValue); }/*w w w .ja va2 s . c o m*/ } else { StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], entry); } } } else { StatementCreatorUtils.setParameterValue(ps, argIndx++, this.argTypes[i], arg); } } } }
From source file:org.snaker.engine.spring.SpringJdbcAccess.java
public void updateProcess(final Process process) { super.updateProcess(process); if (process.getBytes() != null) { template.execute(PROCESS_UPDATE_BLOB, new AbstractLobCreatingPreparedStatementCallback(lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException, DataAccessException { try { lobCreator.setBlobAsBytes(ps, 1, process.getBytes()); StatementCreatorUtils.setParameterValue(ps, 2, Types.VARCHAR, process.getId()); } catch (Exception e) { e.printStackTrace(); }//w ww .j a v a2s . c om } }); } }