List of usage examples for org.springframework.jdbc.core SqlTypeValue TYPE_UNKNOWN
int TYPE_UNKNOWN
To view the source code for org.springframework.jdbc.core SqlTypeValue TYPE_UNKNOWN.
Click Source Link
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 ww . j a va 2s .c om*/ } } 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 ww .ja va 2s . co 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; }/*from ww w . j a v a 2s. 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. j a va 2s.c om } } }
From source file:fr.acxio.tools.agia.item.database.ExpressionsPreparedStatementSetter.java
@Override public synchronized void setValues(PreparedStatement sPs) throws SQLException { try {/*ww w . j av a 2 s . 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:com.gzj.tulip.jade.dataaccess.DataAccessImpl.java
private PreparedStatementCreator getPreparedStatementCreator(// final String sql, final Object[] args, final boolean returnKeys) { PreparedStatementCreator creator = new PreparedStatementCreator() { @Override/*from w ww. j a v a 2s . c o m*/ public PreparedStatement createPreparedStatement(Connection con) throws SQLException { PreparedStatement ps = con.prepareStatement(sql); if (returnKeys) { ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); } else { ps = con.prepareStatement(sql); } if (args != null) { for (int i = 0; i < args.length; i++) { Object arg = 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); } } } return ps; } }; return creator; }
From source file:com.laxser.blitz.lama.provider.jdbc.JdbcImpl.java
@Override public int[] batchUpdate(Modifier modifier, String sql, final List<Object[]> args) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("Executing SQL batch update [" + sql + "]"); }//from w w w . j ava 2 s . co m return spring.batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { Object[] values = args.get(i); for (int j = 0; j < values.length; j++) { Object arg = values[j]; if (arg instanceof SqlParameterValue) { SqlParameterValue paramValue = (SqlParameterValue) arg; StatementCreatorUtils.setParameterValue(ps, j + 1, paramValue, paramValue.getValue()); } else { StatementCreatorUtils.setParameterValue(ps, j + 1, SqlTypeValue.TYPE_UNKNOWN, arg); } } } @Override public int getBatchSize() { return args.size(); } }); }
From source file:com.sinosoft.one.data.jade.dataaccess.DataAccessImpl.java
private void setParams(PreparedStatement ps, Object[] args) throws SQLException { if (args != null) { for (int i = 0; i < args.length; i++) { Object arg = 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. j a va 2 s . c om*/ } } }
From source file:org.jasig.ssp.util.importer.job.staging.SqlServerStagingTableWriter.java
@Override public void write(final List<? extends RawItem> items) { NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource); String fileName = items.get(0).getResource().getFilename(); final String[] tableName = fileName.split("\\."); Integer batchStart = (Integer) (stepExecution.getExecutionContext().get("batchStart") == null ? null : stepExecution.getExecutionContext().get("batchStart")); Integer batchStop = (Integer) (stepExecution.getExecutionContext().get("batchStop") == null ? null : stepExecution.getExecutionContext().get("batchStop")); Object currentEntity = stepExecution.getExecutionContext().get("currentEntity"); if (currentEntity == null || !currentEntity.equals(tableName[0])) { batchStart = 0;// w ww .j a v a 2 s .com batchStop = items.size() - 1; currentEntity = tableName[0]; stepExecution.getExecutionContext().put("currentEntity", currentEntity); stepExecution.getExecutionContext().put("batchStart", batchStart); stepExecution.getExecutionContext().put("batchStop", batchStop); } else { batchStart = batchStop + 1; batchStop = (Integer) batchStart + items.size() - 1; stepExecution.getExecutionContext().put("batchStart", batchStart); stepExecution.getExecutionContext().put("batchStop", batchStop); } RawItem firstItem = items.get(0); Resource firstItemResource = firstItem.getResource(); if (currentResource == null || !(this.currentResource.equals(firstItemResource))) { this.orderedHeaders = writeHeader(firstItem); this.currentResource = firstItemResource; } StringBuilder insertSql = new StringBuilder(); insertSql.append("INSERT INTO stg_" + tableName[0] + " (batch_id,"); StringBuilder valuesSqlBuilder = new StringBuilder(); valuesSqlBuilder.append(" VALUES (?,"); for (String header : this.orderedHeaders) { insertSql.append(header).append(","); valuesSqlBuilder.append("?").append(","); } insertSql.setLength(insertSql.length() - 1); // trim comma valuesSqlBuilder.setLength(valuesSqlBuilder.length() - 1); // trim comma insertSql.append(")"); valuesSqlBuilder.append(");"); insertSql.append(valuesSqlBuilder); final AtomicInteger batchStartRef = new AtomicInteger(batchStart); final String sql = insertSql.toString(); jdbcTemplate.getJdbcOperations().execute(sql, new PreparedStatementCallback() { @Override public Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { for (RawItem item : items) { final List<Object> paramsForLog = new ArrayList(orderedHeaders.length); int counter = 1; paramsForLog.add(batchStartRef.get()); StatementCreatorUtils.setParameterValue(ps, counter, SqlTypeValue.TYPE_UNKNOWN, batchStartRef.getAndIncrement()); counter++; for (String header : orderedHeaders) { final Map<String, String> record = item.getRecord(); String value = record.get(header); final Integer sqlType = metadataRepository.getRepository().getColumnMetadataRepository() .getColumnMetadata(new ColumnReference(tableName[0], header)).getJavaSqlType(); paramsForLog.add(value); StatementCreatorUtils.setParameterValue(ps, counter, sqlType, value); counter++; } sayQuery(sql, paramsForLog); ps.addBatch(); } return ps.executeBatch(); } }); batchStart = batchStartRef.get(); say("******CHUNK SQLSERVER******"); }