List of usage examples for java.sql PreparedStatement setNull
void setNull(int parameterIndex, int sqlType) throws SQLException;
NULL
. From source file:org.apache.jmeter.protocol.jdbc.AbstractJDBCTestElement.java
private void setArgument(PreparedStatement pstmt, String argument, int targetSqlType, int index) throws SQLException { switch (targetSqlType) { case Types.INTEGER: pstmt.setInt(index, Integer.parseInt(argument)); break;/* w w w .j av a 2s .co m*/ case Types.DECIMAL: case Types.NUMERIC: pstmt.setBigDecimal(index, new BigDecimal(argument)); break; case Types.DOUBLE: case Types.FLOAT: pstmt.setDouble(index, Double.parseDouble(argument)); break; case Types.CHAR: case Types.LONGVARCHAR: case Types.VARCHAR: pstmt.setString(index, argument); break; case Types.BIT: case Types.BOOLEAN: pstmt.setBoolean(index, Boolean.parseBoolean(argument)); break; case Types.BIGINT: pstmt.setLong(index, Long.parseLong(argument)); break; case Types.DATE: pstmt.setDate(index, Date.valueOf(argument)); break; case Types.REAL: pstmt.setFloat(index, Float.parseFloat(argument)); break; case Types.TINYINT: pstmt.setByte(index, Byte.parseByte(argument)); break; case Types.SMALLINT: pstmt.setShort(index, Short.parseShort(argument)); break; case Types.TIMESTAMP: pstmt.setTimestamp(index, Timestamp.valueOf(argument)); break; case Types.TIME: pstmt.setTime(index, Time.valueOf(argument)); break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: pstmt.setBytes(index, argument.getBytes()); break; case Types.NULL: pstmt.setNull(index, targetSqlType); break; default: pstmt.setObject(index, argument, targetSqlType); } }
From source file:fll.web.admin.UploadSubjectiveData.java
@SuppressFBWarnings(value = { "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" }, justification = "columns are dynamic") private static void saveCategoryData(final int currentTournament, final Connection connection, final Element scoreCategoryElement, final String categoryName, final ScoreCategory categoryElement) throws SQLException, ParseException { final List<AbstractGoal> goalDescriptions = categoryElement.getGoals(); PreparedStatement insertPrep = null; PreparedStatement updatePrep = null; try {/*from ww w. j av a 2 s. c om*/ // prepare statements for update and insert final StringBuffer updateStmt = new StringBuffer(); final StringBuffer insertSQLColumns = new StringBuffer(); insertSQLColumns.append("INSERT INTO " + categoryName + " (TeamNumber, Tournament, Judge, NoShow"); final StringBuffer insertSQLValues = new StringBuffer(); insertSQLValues.append(") VALUES ( ?, ?, ?, ?"); updateStmt.append("UPDATE " + categoryName + " SET NoShow = ? "); final int numGoals = goalDescriptions.size(); for (final AbstractGoal goalDescription : goalDescriptions) { insertSQLColumns.append(", " + goalDescription.getName()); insertSQLValues.append(", ?"); updateStmt.append(", " + goalDescription.getName() + " = ?"); } updateStmt.append(" WHERE TeamNumber = ? AND Tournament = ? AND Judge = ?"); updatePrep = connection.prepareStatement(updateStmt.toString()); insertPrep = connection .prepareStatement(insertSQLColumns.toString() + insertSQLValues.toString() + ")"); // initialze the tournament insertPrep.setInt(2, currentTournament); updatePrep.setInt(numGoals + 3, currentTournament); for (final Element scoreElement : new NodelistElementCollectionAdapter( scoreCategoryElement.getElementsByTagName("score"))) { if (scoreElement.hasAttribute("modified") && "true".equalsIgnoreCase(scoreElement.getAttribute("modified"))) { final int teamNumber = Utilities.NUMBER_FORMAT_INSTANCE .parse(scoreElement.getAttribute("teamNumber")).intValue(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Saving score data for team: " + teamNumber); } final String judgeId = scoreElement.getAttribute("judge"); final boolean noShow = Boolean.parseBoolean(scoreElement.getAttribute("NoShow")); updatePrep.setBoolean(1, noShow); insertPrep.setBoolean(4, noShow); insertPrep.setInt(1, teamNumber); updatePrep.setInt(numGoals + 2, teamNumber); insertPrep.setString(3, judgeId); updatePrep.setString(numGoals + 4, judgeId); int goalIndex = 0; for (final AbstractGoal goalDescription : goalDescriptions) { final String goalName = goalDescription.getName(); final Element subscoreElement = SubjectiveUtils.getSubscoreElement(scoreElement, goalName); if (null == subscoreElement) { // no subscore element, no show or deleted insertPrep.setNull(goalIndex + 5, Types.DOUBLE); updatePrep.setNull(goalIndex + 2, Types.DOUBLE); } else { final String value = subscoreElement.getAttribute("value"); if (!value.trim().isEmpty()) { insertPrep.setString(goalIndex + 5, value.trim()); updatePrep.setString(goalIndex + 2, value.trim()); } else { insertPrep.setNull(goalIndex + 5, Types.DOUBLE); updatePrep.setNull(goalIndex + 2, Types.DOUBLE); } } ++goalIndex; } // end for // attempt the update first final int modifiedRows = updatePrep.executeUpdate(); if (modifiedRows < 1) { // do insert if nothing was updated insertPrep.executeUpdate(); } } } } finally { SQLFunctions.close(insertPrep); SQLFunctions.close(updatePrep); } }
From source file:com.flexive.ejb.beans.BriefcaseEngineBean.java
/** * {@inheritDoc}//from w w w . ja va2s .co m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void addItemData(long briefcaseId, BriefcaseItemData itemData) throws FxApplicationException { if (itemData == null) return; Briefcase br = load(briefcaseId); // check read permissions Connection con = null; PreparedStatement stmt = null; try { con = Database.getDbConnection(); // check if the item actually exists stmt = con.prepareStatement( "SELECT COUNT(*) FROM " + TBL_BRIEFCASE_DATA + " WHERE briefcase_id=? AND id=?"); stmt.setLong(1, briefcaseId); stmt.setLong(2, itemData.getId()); ResultSet rs = stmt.executeQuery(); if (rs == null || !rs.next() || rs.getLong(1) != 1) throw new FxNotFoundException(LOG, "ex.briefcase.notFound.item", itemData.getId(), br.getName()); stmt.close(); stmt = con.prepareStatement( "SELECT MAX(pos) FROM " + TBL_BRIEFCASE_DATA_ITEM + " WHERE briefcase_id=? AND id=?"); stmt.setLong(1, briefcaseId); stmt.setLong(2, itemData.getId()); rs = stmt.executeQuery(); int pos = rs.next() ? rs.getInt(1) : 0; stmt.close(); stmt = con.prepareStatement("INSERT INTO " + TBL_BRIEFCASE_DATA_ITEM + "(briefcase_id, id, pos, intflag1, intflag2, intflag3, longflag1, longflag2, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); stmt.setLong(1, briefcaseId); stmt.setLong(2, itemData.getId()); stmt.setLong(3, ++pos); if (itemData.isIntFlagSet(1)) stmt.setInt(4, itemData.getIntFlag1()); else stmt.setNull(4, Types.INTEGER); if (itemData.isIntFlagSet(2)) stmt.setInt(5, itemData.getIntFlag2()); else stmt.setNull(5, Types.INTEGER); if (itemData.isIntFlagSet(3)) stmt.setInt(6, itemData.getIntFlag3()); else stmt.setNull(6, Types.INTEGER); if (itemData.isLongFlagSet(1)) stmt.setLong(7, itemData.getLongFlag1()); else stmt.setNull(7, Types.BIGINT); if (itemData.isLongFlagSet(2)) stmt.setLong(8, itemData.getLongFlag2()); else stmt.setNull(8, Types.BIGINT); stmt.setString(9, itemData.getMetaData()); stmt.executeUpdate(); } catch (Exception e) { EJBUtils.rollback(ctx); throw new FxUpdateException(LOG, e, "ex.briefcase.addItemData", br.getName(), itemData.getId(), e.getMessage()); } finally { Database.closeObjects(BriefcaseEngineBean.class, con, stmt); } }
From source file:org.apache.qpid.server.store.derby.DerbyMessageStore.java
private void updateConfiguredObject(final ConfiguredObjectRecord configuredObject) throws AMQStoreException { if (_stateManager.isInState(State.ACTIVE)) { try {/* w w w .ja v a 2 s . c o m*/ Connection conn = newAutoCommitConnection(); try { PreparedStatement stmt = conn.prepareStatement(FIND_CONFIGURED_OBJECT); try { stmt.setString(1, configuredObject.getId().toString()); ResultSet rs = stmt.executeQuery(); try { if (rs.next()) { PreparedStatement stmt2 = conn.prepareStatement(UPDATE_CONFIGURED_OBJECTS); try { stmt2.setString(1, configuredObject.getType()); if (configuredObject.getAttributes() != null) { byte[] attributesAsBytes = configuredObject.getAttributes() .getBytes(UTF8_CHARSET); ByteArrayInputStream bis = new ByteArrayInputStream(attributesAsBytes); stmt2.setBinaryStream(2, bis, attributesAsBytes.length); } else { stmt2.setNull(2, Types.BLOB); } stmt2.setString(3, configuredObject.getId().toString()); stmt2.execute(); } finally { stmt2.close(); } } } finally { rs.close(); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException e) { throw new AMQStoreException( "Error updating configured object " + configuredObject + " in database: " + e.getMessage(), e); } } }
From source file:dk.netarkivet.harvester.datamodel.DomainDBDAO.java
/** * Insert new harvest info for a domain. * @param c //from www .j a va 2 s. c om * A connection to the database * @param d * A domain to insert on. The domains ID must be correct. * @param harvestInfo * Harvest info to insert. */ private void insertHarvestInfo(Connection c, Domain d, HarvestInfo harvestInfo) { PreparedStatement s = null; try { // Note that the config_id is grabbed from the configurations table. s = c.prepareStatement( "INSERT INTO historyinfo " + "( stopreason, objectcount, bytecount, config_id, " + "job_id, harvest_id, harvest_time ) " + "VALUES ( ?, ?, ?, ?, ?, ?, ? )", Statement.RETURN_GENERATED_KEYS); s.setInt(1, harvestInfo.getStopReason().ordinal()); s.setLong(2, harvestInfo.getCountObjectRetrieved()); s.setLong(3, harvestInfo.getSizeDataRetrieved()); // TODO More stable way to get IDs, use a select s.setLong(4, d.getConfiguration(harvestInfo.getDomainConfigurationName()).getID()); if (harvestInfo.getJobID() != null) { s.setLong(5, harvestInfo.getJobID()); } else { s.setNull(5, Types.BIGINT); } s.setLong(6, harvestInfo.getHarvestID()); s.setTimestamp(7, new Timestamp(harvestInfo.getDate().getTime())); s.executeUpdate(); harvestInfo.setID(DBUtils.getGeneratedID(s)); } catch (SQLException e) { throw new IOFailure("SQL error while inserting harvest info " + harvestInfo + " for " + d + "\n" + ExceptionUtils.getSQLExceptionCause(e), e); } }
From source file:com.flexive.core.storage.genericSQL.GenericTreeStorageSimple.java
/** * {@inheritDoc}/*from ww w . j a va 2 s . c om*/ */ @Override public long createNode(Connection con, SequencerEngine seq, ContentEngine ce, FxTreeMode mode, long nodeId, long parentNodeId, String name, FxString label, int position, FxPK reference, String data, boolean activateContent) throws FxApplicationException { checkDataValue(data); NodeCreateInfo nci = getNodeCreateInfo(mode, seq, ce, nodeId, name, label, reference, true); FxTreeNodeInfo parentNode = getTreeNodeInfo(con, mode, parentNodeId); long left, right; if (position < 0) position = 0; else if (position > parentNode.getDirectChildCount()) position = parentNode.getDirectChildCount(); // Create the node PreparedStatement ps = null; try { if (position == 0) { //first entry left = parentNode.getLeft().longValue() + 1; } else if (parentNode.getDirectChildCount() >= position) { //last entry left = parentNode.getRight().longValue(); } else { //inbetween - calculate needed left/right slot ps = con.prepareStatement("SELECT RGT FROM " + getTable(mode) + " WHERE PARENT=? ORDER BY LFT LIMIT 1 OFFSET " + position); ps.setLong(1, parentNodeId); ResultSet rs = ps.executeQuery(); if (rs == null || !rs.next()) { throw new FxTreeException("ex.tree.create.failed.positioning", parentNodeId, position); } left = rs.getLong(1); ps.close(); } right = left + 1; //"move" nodes to the right to make space ps = con.prepareStatement("UPDATE " + getTable(mode) + " SET RGT=RGT+2 WHERE RGT>=?"); ps.setLong(1, left); ps.executeUpdate(); ps.close(); ps = con.prepareStatement("UPDATE " + getTable(mode) + " SET LFT=LFT+2 WHERE LFT>?"); ps.setLong(1, right); ps.executeUpdate(); ps.close(); //insert the new node ps = con.prepareStatement("INSERT INTO " + getTable(mode) + " (ID,PARENT,DEPTH,DIRTY,REF,LFT,RGT," + "CHILDCOUNT,NAME,MODIFIED_AT,TEMPLATE) VALUES " + "(" + nci.id + "," + parentNodeId + "," + (parentNode.getDepth() + 1) + ",?," + nci.reference.getId() + ",?,?,0,0,?," + StorageManager.getTimestampFunction() + ",?)"); ps.setBoolean(1, mode != FxTreeMode.Live); ps.setLong(2, left); ps.setLong(3, right); ps.setString(4, nci.name); if (StringUtils.isEmpty(data)) { ps.setNull(5, java.sql.Types.VARCHAR); } else { ps.setString(6, data); } ps.executeUpdate(); ps.close(); //update the parents childcount ps = con.prepareStatement( "UPDATE " + getTable(mode) + " SET CHILDCOUNT=CHILDCOUNT+1 WHERE ID=" + parentNodeId); ps.executeUpdate(); } catch (SQLException e) { throw new FxTreeException(e, "ex.db.sqlError", e.getMessage()); } finally { try { if (ps != null) ps.close(); } catch (Throwable t) { /*ignore*/ } } return nci.id; }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertOpenbareRuimten(final List<OpenbareRuimte> openbareRuimten) throws DAOException { try {// w ww . j a v a2 s .com jdbcTemplate.batchUpdate("insert into bag_openbare_ruimte (" + "bag_openbare_ruimte_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "openbare_ruimte_naam," + "officieel," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "openbare_ruimte_type," + "bron_documentdatum," + "bron_documentnummer," + "openbareruimte_status," + "bag_woonplaats_id," + "verkorte_openbare_ruimte_naam" + ") values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, openbareRuimten.get(i).getIdentificatie()); ps.setInt(2, openbareRuimten.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, openbareRuimten.get(i).getAanduidingRecordCorrectie()); ps.setString(4, openbareRuimten.get(i).getOpenbareRuimteNaam()); ps.setInt(5, openbareRuimten.get(i).getOfficieel().ordinal()); ps.setTimestamp(6, new Timestamp( openbareRuimten.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (openbareRuimten.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(7, Types.TIMESTAMP); else ps.setTimestamp(7, new Timestamp( openbareRuimten.get(i).getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(8, openbareRuimten.get(i).getInOnderzoek().ordinal()); ps.setInt(9, openbareRuimten.get(i).getOpenbareRuimteType().ordinal()); ps.setDate(10, new Date(openbareRuimten.get(i).getDocumentdatum().getTime())); ps.setString(11, openbareRuimten.get(i).getDocumentnummer()); ps.setInt(12, openbareRuimten.get(i).getOpenbareruimteStatus().ordinal()); ps.setLong(13, openbareRuimten.get(i).getGerelateerdeWoonplaats()); ps.setString(14, openbareRuimten.get(i).getVerkorteOpenbareRuimteNaam()); } @Override public int getBatchSize() { return openbareRuimten.size(); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting openbare ruimten", e); } }
From source file:com.funambol.foundation.items.dao.DataBaseFileDataObjectMetadataDAO.java
/** * Adds file data object metadata of an item to the database. * @param fdow// w w w . j a va 2 s. co m * @throws com.funambol.foundation.exception.DAOException */ public String addItem(FileDataObjectWrapper fdow) throws DAOException { Connection con = null; PreparedStatement ps = null; try { // Looks up the data source when the first connection is created con = getUserDataSource().getRoutedConnection(userId); if (fdow.getId() == null) { throw new DAOException("Unable to add item: id should be already defined"); } ps = con.prepareStatement(SQL_INSERT_INTO_FNBL_FILE_DATA_OBJECT); int k = 1; ps.setLong(k++, Long.parseLong(fdow.getId())); ps.setString(k++, userId); ps.setString(k++, sourceURI); Timestamp currentTime = new Timestamp(System.currentTimeMillis()); Timestamp lastUpdate = fdow.getLastUpdate(); if (lastUpdate == null) { lastUpdate = currentTime; } ps.setLong(k++, lastUpdate.getTime()); ps.setString(k++, String.valueOf(SyncItemState.NEW)); FileDataObject fdo = fdow.getFileDataObject(); ps.setString(k++, String.valueOf(fdo.getUploadStatus())); String fileName = fdow.getLocalName(); if (fileName == null || fileName.length() == 0) { ps.setNull(k++, Types.VARCHAR); } else { ps.setString(k++, StringUtils.left(fileName, SQL_LOCAL_NAME_DIM)); } Long crc = Long.valueOf(fdow.getFileDataObject().getCrc()); ps.setLong(k++, crc); ps.setString(k++, StringUtils.left(fdo.getName(), SQL_TRUE_NAME_DIM)); MediaUtils.setFDODates(fdo, fdo.getCreated(), fdo.getModified()); Timestamp created = timestamp(fdo.getCreated()); if (created != null) { ps.setTimestamp(k++, created); } else { ps.setTimestamp(k++, currentTime); } Timestamp modified = timestamp(fdo.getModified()); if (modified != null) { ps.setTimestamp(k++, modified); } else { ps.setTimestamp(k++, currentTime); } ps.setTimestamp(k++, timestamp(fdo.getAccessed())); ps.setString(k++, fdo.isHidden() ? ONE : NIL); ps.setString(k++, fdo.isSystem() ? ONE : NIL); ps.setString(k++, fdo.isArchived() ? ONE : NIL); ps.setString(k++, fdo.isDeleted() ? ONE : NIL); ps.setString(k++, fdo.isWritable() ? ONE : NIL); ps.setString(k++, fdo.isReadable() ? ONE : NIL); ps.setString(k++, fdo.isExecutable() ? ONE : NIL); if (fdo.getContentType() != null) { ps.setString(k++, StringUtils.left(fdo.getContentType(), SQL_CTTYPE_DIM)); } else { ps.setNull(k++, Types.VARCHAR); } if (fdo.getSize() == null) { ps.setNull(k++, Types.BIGINT); } else { ps.setLong(k++, fdo.getSize()); } if (fdow.getSizeOnStorage() == null) { ps.setNull(k++, Types.BIGINT); } else { ps.setLong(k++, fdow.getSizeOnStorage()); } ps.executeUpdate(); DBTools.close(null, ps, null); // stores file data object properties addProperties(fdow); } catch (Exception e) { throw new DAOException("Error adding file data object.", e); } finally { DBTools.close(con, ps, null); } return fdow.getId(); }
From source file:net.sf.farrago.namespace.sfdc.SfdcUdx.java
public static void query(String query, String types, PreparedStatement resultInserter) throws SQLException { SoapBindingStub binding = (SoapBindingStub) FarragoUdrRuntime.getDataServerRuntimeSupport(null); try {//from ww w .j a va 2 s . com QueryOptions qo = new QueryOptions(); int batchsize = 500; qo.setBatchSize(new Integer(batchsize)); binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "QueryOptions", qo); String objName = query; int fromIdx = query.lastIndexOf(" from"); if (fromIdx > 0) { objName = query.substring(fromIdx + 6); } // strip off quotes for boolean values query = stripQuotes(query, objName); log.info("SFDC Query: " + query); QueryResult qr = binding.query(query); if (qr.isDone()) { if (qr.getRecords() != null) { log.info(SfdcResource.instance().RetrievedAllRecordsMsg .str(Integer.toString(qr.getRecords().length), objName)); } } else { if (qr.getRecords() != null) { log.info(SfdcResource.instance().RetrievingRecordsMsg .str(Integer.toString(qr.getRecords().length), objName)); } } SObject[] records = qr.getRecords(); String[] metadataType = types.split(","); // query is of following format: // "select col1,col2,... from" String cols = query.substring(7); fromIdx = cols.lastIndexOf(" from"); cols = cols.substring(0, fromIdx); cols = cols.trim(); String[] columnValues = new String[metadataType.length]; if (records != null) { boolean bContinue = true; while (bContinue) { // for each record returned in query, // get value of each field for (int i = 0; i < records.length; i++) { MessageElement[] elements = records[i].get_any(); if (elements != null) { for (int j = 0; j < elements.length; j++) { MessageElement elt = elements[j]; String eltVal = elt.getValue(); columnValues[j] = (eltVal != null) ? eltVal : "null"; if (metadataType[j].indexOf("TIMESTAMP") != -1) { // TIMESTAMP if (eltVal != null) { String tstampstr = eltVal.replace("T", " "); tstampstr = tstampstr.substring(0, tstampstr.indexOf(".")); java.sql.Timestamp tstamp = java.sql.Timestamp.valueOf(tstampstr); resultInserter.setTimestamp(j + 1, tstamp); } else { resultInserter.setNull(j + 1, java.sql.Types.TIMESTAMP); } } else if (metadataType[j].indexOf("TIME") != -1) { // TIME if (eltVal != null) { String timestr = eltVal.substring(0, eltVal.indexOf(".")); java.sql.Time time = java.sql.Time.valueOf(timestr); resultInserter.setTime(j + 1, time); } else { resultInserter.setNull(j + 1, java.sql.Types.TIME); } } else if (metadataType[j].indexOf("DATE") != -1) { // DATE if (eltVal != null) { java.sql.Date dt = java.sql.Date.valueOf(eltVal); resultInserter.setDate(j + 1, dt); } else { resultInserter.setNull(j + 1, java.sql.Types.DATE); } } else if (metadataType[j].indexOf("INTEGER") != -1) { // INTEGER if (eltVal != null) { int iValue = 0; iValue = Integer.parseInt(eltVal); resultInserter.setInt(j + 1, iValue); } else { resultInserter.setNull(j + 1, java.sql.Types.INTEGER); } } else if (metadataType[j].indexOf("DOUBLE") != -1) { // DOUBLE if (eltVal != null) { resultInserter.setDouble(j + 1, Double.parseDouble(eltVal)); } else { resultInserter.setNull(j + 1, java.sql.Types.DOUBLE); } } else if (eltVal != null) { // VARCHAR - default int rightParen = metadataType[j].indexOf(")"); int prec = Integer.parseInt(metadataType[j].substring(8, rightParen)); if (eltVal.length() > prec) { eltVal = eltVal.substring(0, prec); columnValues[j] = eltVal; } resultInserter.setString(j + 1, eltVal); } else { resultInserter.setNull(j + 1, java.sql.Types.VARCHAR); } } resultInserter.executeUpdate(); } } if (qr.isDone()) { bContinue = false; } else { boolean relogin = true; int retryCnt = 0; while (relogin) { try { qr = binding.queryMore(qr.getQueryLocator()); relogin = false; } catch (AxisFault a) { if (a.getFaultString().contains("Invalid Session ID") && (retryCnt < RETRY_CNT)) { relogin = true; retryCnt++; binding = (SoapBindingStub) FarragoUdrRuntime .getDataServerRuntimeSupport(binding); } else { throw a; } } } records = qr.getRecords(); if (qr.isDone()) { if (qr.getRecords() != null) { log.info(SfdcResource.instance().RetrievedAllRecordsMsg .str(Integer.toString(qr.getRecords().length), objName)); } } else { if (qr.getRecords() != null) { log.info(SfdcResource.instance().RetrievingRecordsMsg .str(Integer.toString(qr.getRecords().length), objName)); } } } } } } catch (AxisFault ae) { SQLException retryExcn = new SQLException(ae.getFaultString(), null, 460150); Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn); throw SfdcResource.instance().BindingCallException.ex(ae.getFaultString(), chainedEx); } catch (RemoteException re) { SQLException retryExcn = new SQLException(re.getMessage(), null, 460150); Exception chainedEx = FarragoResource.instance().RetryableFailure.ex(retryExcn); throw SfdcResource.instance().BindingCallException.ex(re.getMessage(), chainedEx); } }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertWoonplaatsen(final List<Woonplaats> woonplaatsen) throws DAOException { try {// w w w . j av a 2 s . c om jdbcTemplate.batchUpdate("insert into bag_woonplaats (" + "bag_woonplaats_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "woonplaats_naam," + "woonplaats_geometrie," + "officieel," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer," + "woonplaats_status" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, woonplaatsen.get(i).getIdentificatie()); ps.setInt(2, woonplaatsen.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, woonplaatsen.get(i).getAanduidingRecordCorrectie()); ps.setString(4, woonplaatsen.get(i).getWoonplaatsNaam()); ps.setString(5, woonplaatsen.get(i).getWoonplaatsGeometrie()); ps.setInt(6, woonplaatsen.get(i).getOfficieel().ordinal()); ps.setTimestamp(7, new Timestamp(woonplaatsen.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (woonplaatsen.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(8, Types.TIMESTAMP); else ps.setTimestamp(8, new Timestamp( woonplaatsen.get(i).getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(9, woonplaatsen.get(i).getInOnderzoek().ordinal()); ps.setDate(10, new Date(woonplaatsen.get(i).getDocumentdatum().getTime())); ps.setString(11, woonplaatsen.get(i).getDocumentnummer()); ps.setInt(12, woonplaatsen.get(i).getWoonplaatsStatus().ordinal()); } @Override public int getBatchSize() { return woonplaatsen.size(); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting woonplaatsen", e); } }