List of usage examples for java.sql ResultSet getShort
short getShort(String columnLabel) throws SQLException;
ResultSet
object as a short
in the Java programming language. From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAddressTable.java
protected CFAccAddressBuff unpackAddressResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAddressResultSetToBuff"; int idxcol = 1; CFAccAddressBuff buff = schema.getFactoryAddress().newBuff(); {/* w w w .j a v a2s.c om*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccOracleSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccOracleSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAddressId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredContactId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalAddrLine1(null); } else { buff.setOptionalAddrLine1(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalAddrLine2(null); } else { buff.setOptionalAddrLine2(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalCity(null); } else { buff.setOptionalCity(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalState(null); } else { buff.setOptionalState(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCountryId(null); } else { buff.setOptionalCountryId(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalZip(null); } else { buff.setOptionalZip(colVal); } } idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:com.streamsets.pipeline.stage.origin.jdbc.cdc.oracle.OracleCDCSource.java
private void generateRecords(Offset startingOffset, PreparedStatement selectChanges) { // When this is called the first time, Logminer was started either from SCN or from a start date, so we just keep // track of the start date etc. LOG.info("Attempting to generate records"); boolean error; StringBuilder query = new StringBuilder(); BigDecimal lastCommitSCN = new BigDecimal(startingOffset.scn); int sequenceNumber = startingOffset.sequence; LocalDateTime startTime = adjustStartTime(startingOffset.timestamp); String lastTxnId = startingOffset.txnId; LocalDateTime endTime = getEndTimeForStartTime(startTime); ResultSet resultSet = null; while (!getContext().isStopped()) { error = false;/*from w ww . j av a 2 s. c o m*/ generationStarted = true; try { recordQueue.put(new RecordOffset(dummyRecord, new Offset(version, startTime, lastCommitSCN.toPlainString(), sequenceNumber, lastTxnId))); selectChanges = getSelectChangesStatement(); if (!useLocalBuffering) { selectChanges.setBigDecimal(1, lastCommitSCN); selectChanges.setInt(2, sequenceNumber); selectChanges.setBigDecimal(3, lastCommitSCN); if (shouldTrackDDL) { selectChanges.setBigDecimal(4, lastCommitSCN); } } selectChanges.setFetchSize(configBean.jdbcFetchSize); resultSet = selectChanges.executeQuery(); while (resultSet.next() && !getContext().isStopped()) { String queryFragment = resultSet.getString(5); BigDecimal scnDecimal = resultSet.getBigDecimal(1); String scn = scnDecimal.toPlainString(); String xidUsn = String.valueOf(resultSet.getLong(10)); String xidSlt = String.valueOf(resultSet.getString(11)); String xidSqn = String.valueOf(resultSet.getString(12)); String xid = xidUsn + "." + xidSlt + "." + xidSqn; // Query Fragment is not null -> we need to process // Query Fragment is null AND the query string buffered from previous rows due to CSF == 0 is null, // nothing to do, go to next row // Query Fragment is null, but there is previously buffered data in the query, go ahead and process. if (queryFragment != null) { query.append(queryFragment); } else if (queryFragment == null && query.length() == 0) { LOG.debug(READ_NULL_QUERY_FROM_ORACLE, scn, xid); continue; } // CSF is 1 if the query is incomplete, so read the next row before parsing // CSF being 0 means query is complete, generate the record if (resultSet.getInt(9) == 0) { if (query.length() == 0) { LOG.debug(READ_NULL_QUERY_FROM_ORACLE, scn, xid); continue; } String queryString = query.toString(); query.setLength(0); String username = resultSet.getString(2); short op = resultSet.getShort(3); String timestamp = resultSet.getString(4); LocalDateTime tsDate = Timestamp.valueOf(timestamp).toLocalDateTime(); delay.getValue().put("delay", getDelay(tsDate)); String table = resultSet.getString(6); BigDecimal commitSCN = resultSet.getBigDecimal(7); int seq = resultSet.getInt(8); String rsId = resultSet.getString(13); Object ssn = resultSet.getObject(14); String schema = String.valueOf(resultSet.getString(15)); int rollback = resultSet.getInt(16); String rowId = resultSet.getString(17); SchemaAndTable schemaAndTable = new SchemaAndTable(schema, table); TransactionIdKey key = new TransactionIdKey(xid); bufferedRecordsLock.lock(); try { if (useLocalBuffering && bufferedRecords.containsKey(key) && bufferedRecords.get(key) .contains(new RecordSequence(null, null, 0, 0, rsId, ssn, null))) { continue; } } finally { bufferedRecordsLock.unlock(); } Offset offset = null; if (LOG.isDebugEnabled()) { LOG.debug( "Commit SCN = {}, SCN = {}, Operation = {}, Txn Id = {}, Timestamp = {}, Row Id = {}, Redo SQL = {}", commitSCN, scn, op, xid, tsDate, rowId, queryString); } if (op != DDL_CODE && op != COMMIT_CODE && op != ROLLBACK_CODE) { if (!useLocalBuffering) { offset = new Offset(version, tsDate, commitSCN.toPlainString(), seq, xid); } Map<String, String> attributes = new HashMap<>(); attributes.put(SCN, scn); attributes.put(USER, username); attributes.put(TIMESTAMP_HEADER, timestamp); attributes.put(TABLE, table); attributes.put(SEQ, String.valueOf(seq)); attributes.put(XID, xid); attributes.put(RS_ID, rsId); attributes.put(SSN, ssn.toString()); attributes.put(SCHEMA, schema); attributes.put(ROLLBACK, String.valueOf(rollback)); attributes.put(ROWID_KEY, rowId); if (!useLocalBuffering || getContext().isPreview()) { if (commitSCN.compareTo(lastCommitSCN) < 0 || (commitSCN.compareTo(lastCommitSCN) == 0 && seq < sequenceNumber)) { continue; } lastCommitSCN = commitSCN; sequenceNumber = seq; if (configBean.keepOriginalQuery) { attributes.put(QUERY_KEY, queryString); } try { Record record = generateRecord(queryString, attributes, op); if (record != null && record.getEscapedFieldPaths().size() > 0) { recordQueue.put(new RecordOffset(record, offset)); } } catch (UnparseableSQLException ex) { LOG.error("Parsing failed", ex); unparseable.offer(queryString); } } else { bufferedRecordsLock.lock(); try { HashQueue<RecordSequence> records = bufferedRecords.computeIfAbsent(key, x -> { x.setTxnStartTime(tsDate); return createTransactionBuffer(key.txnId); }); int nextSeq = records.isEmpty() ? 1 : records.tail().seq + 1; RecordSequence node = new RecordSequence(attributes, queryString, nextSeq, op, rsId, ssn, tsDate); records.add(node); } finally { bufferedRecordsLock.unlock(); } } } else if (!getContext().isPreview() && useLocalBuffering && (op == COMMIT_CODE || op == ROLLBACK_CODE)) { // so this commit was previously processed or it is a rollback, so don't care. if (op == ROLLBACK_CODE || scnDecimal.compareTo(lastCommitSCN) < 0) { bufferedRecordsLock.lock(); try { bufferedRecords.remove(key); } finally { bufferedRecordsLock.unlock(); } } else { bufferedRecordsLock.lock(); try { HashQueue<RecordSequence> records = bufferedRecords.getOrDefault(key, EMPTY_LINKED_HASHSET); if (lastCommitSCN.equals(scnDecimal) && xid.equals(lastTxnId)) { removeProcessedRecords(records, sequenceNumber); } int bufferedRecordsToBeRemoved = records.size(); LOG.debug(FOUND_RECORDS_IN_TRANSACTION, bufferedRecordsToBeRemoved, xid); lastCommitSCN = scnDecimal; lastTxnId = xid; sequenceNumber = addRecordsToQueue(tsDate, scn, xid); } finally { bufferedRecordsLock.unlock(); } } } else { offset = new Offset(version, tsDate, scn, 0, xid); boolean sendSchema = false; // Commit/rollback in Preview will also end up here, so don't really do any of the following in preview // Don't bother with DDL events here. if (!getContext().isPreview()) { // Event is sent on every DDL, but schema is not always sent. // Schema sending logic: // CREATE/ALTER: Schema is sent if the schema after the ALTER is newer than the cached schema // (which we would have sent as an event earlier, at the last alter) // DROP/TRUNCATE: Schema is not sent, since they don't change schema. DDL_EVENT type = getDdlType(queryString); if (type == DDL_EVENT.ALTER || type == DDL_EVENT.CREATE) { sendSchema = refreshSchema(scnDecimal, new SchemaAndTable(schema, table)); } recordQueue.put(new RecordOffset(createEventRecord(type, queryString, schemaAndTable, offset.toString(), sendSchema, timestamp), offset)); } } query.setLength(0); } } } catch (SQLException ex) { error = true; // force a restart from the same timestamp. if (ex.getErrorCode() == MISSING_LOG_FILE) { LOG.warn("SQL Exception while retrieving records", ex); addToStageExceptionsQueue(new StageException(JDBC_86, ex)); } else if (ex.getErrorCode() != RESULTSET_CLOSED_AS_LOGMINER_SESSION_CLOSED) { LOG.warn("SQL Exception while retrieving records", ex); } else if (ex.getErrorCode() == QUERY_TIMEOUT) { LOG.warn("LogMiner select query timed out"); } else if (ex.getErrorCode() == LOGMINER_START_MUST_BE_CALLED) { LOG.warn("Last LogMiner session did not start successfully. Will retry", ex); } else { LOG.error("Error while reading data", ex); addToStageExceptionsQueue(new StageException(JDBC_52, ex)); } } catch (StageException e) { LOG.error("Error while reading data", e); error = true; addToStageExceptionsQueue(e); } catch (InterruptedException ex) { LOG.error("Interrupted while waiting to add data"); Thread.currentThread().interrupt(); } catch (Exception ex) { LOG.error("Error while reading data", ex); error = true; addToStageExceptionsQueue(new StageException(JDBC_52, ex)); } finally { // If an incomplete batch is seen, it means we are going to move the window forward // Ending this session and starting a new one helps reduce PGA memory usage. try { if (resultSet != null && !resultSet.isClosed()) { resultSet.close(); } if (selectChanges != null && !selectChanges.isClosed()) { selectChanges.close(); } } catch (SQLException ex) { LOG.warn("Error while attempting to close SQL statements", ex); } try { endLogMnr.execute(); } catch (SQLException ex) { LOG.warn("Error while trying to close logminer session", ex); } try { if (error) { resetConnectionsQuietly(); } else { discardOldUncommitted(startTime); startTime = adjustStartTime(endTime); endTime = getEndTimeForStartTime(startTime); } startLogMinerUsingGivenDates(startTime.format(dateTimeColumnHandler.dateFormatter), endTime.format(dateTimeColumnHandler.dateFormatter)); } catch (SQLException ex) { LOG.error("Error while attempting to start LogMiner", ex); addToStageExceptionsQueue(new StageException(JDBC_52, ex)); } catch (StageException ex) { LOG.error("Error while attempting to start logminer for redo log dictionary", ex); addToStageExceptionsQueue(ex); } } } }
From source file:com.nway.spring.jdbc.bean.JavassistBeanProcessor.java
private Object processColumn(ResultSet rs, int index, Class<?> propType, String writer, StringBuilder handler) throws SQLException { if (propType.equals(String.class)) { handler.append("bean.").append(writer).append("(").append("$1.getString(").append(index).append("));"); return rs.getString(index); } else if (propType.equals(Integer.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getInt(").append(index).append("));"); return rs.getInt(index); } else if (propType.equals(Integer.class)) { handler.append("bean.").append(writer).append("(").append("integerValue($1.getInt(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Integer.class); } else if (propType.equals(Long.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getLong(").append(index).append("));"); return rs.getLong(index); } else if (propType.equals(Long.class)) { handler.append("bean.").append(writer).append("(").append("longValue($1.getLong(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Long.class); } else if (propType.equals(java.sql.Date.class)) { handler.append("bean.").append(writer).append("(").append("$1.getDate(").append(index).append("));"); return rs.getDate(index); } else if (propType.equals(java.util.Date.class) || propType.equals(Timestamp.class)) { handler.append("bean.").append(writer).append("(").append("$1.getTimestamp(").append(index) .append("));"); return rs.getTimestamp(index); } else if (propType.equals(Double.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getDouble(").append(index).append("));"); return rs.getDouble(index); } else if (propType.equals(Double.class)) { handler.append("bean.").append(writer).append("(").append("doubleValue($1.getDouble(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Double.class); } else if (propType.equals(Float.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getFloat(").append(index).append("));"); return rs.getFloat(index); } else if (propType.equals(Float.class)) { handler.append("bean.").append(writer).append("(").append("floatValue($1.getFloat(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Float.class); } else if (propType.equals(Time.class)) { handler.append("bean.").append(writer).append("(").append("$1.getTime(").append(index).append("));"); return rs.getTime(index); } else if (propType.equals(Boolean.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getBoolean(").append(index).append("));"); return rs.getBoolean(index); } else if (propType.equals(Boolean.class)) { handler.append("bean.").append(writer).append("(").append("booleanValue($1.getBoolean(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Boolean.class); } else if (propType.equals(byte[].class)) { handler.append("bean.").append(writer).append("(").append("$1.getBytes(").append(index).append("));"); return rs.getBytes(index); } else if (BigDecimal.class.equals(propType)) { handler.append("bean.").append(writer).append("(").append("$1.getBigDecimal(").append(index) .append("));"); return rs.getBigDecimal(index); } else if (Blob.class.equals(propType)) { handler.append("bean.").append(writer).append("(").append("$1.getBlob(").append(index).append("));"); return rs.getBlob(index); } else if (Clob.class.equals(propType)) { handler.append("bean.").append(writer).append("(").append("$1.getClob(").append(index).append("));"); return rs.getClob(index); } else if (propType.equals(Short.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getShort(").append(index).append("));"); return rs.getShort(index); } else if (propType.equals(Short.class)) { handler.append("bean.").append(writer).append("(").append("shortValue($1.getShort(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Short.class); } else if (propType.equals(Byte.TYPE)) { handler.append("bean.").append(writer).append("(").append("$1.getByte(").append(index).append("));"); return rs.getByte(index); } else if (propType.equals(Byte.class)) { handler.append("bean.").append(writer).append("(").append("byteValue($1.getByte(").append(index) .append("),$1.wasNull()));"); return JdbcUtils.getResultSetValue(rs, index, Byte.class); } else {/*from w w w . java 2 s.co m*/ handler.append("bean.").append(writer).append("(").append("(").append(propType.getName()).append(")") .append("$1.getObject(").append(index).append("));"); return rs.getObject(index); } }
From source file:com.github.woonsan.jdbc.jcr.impl.JcrJdbcResultSetTest.java
@SuppressWarnings("deprecation") @Test/* w ww . j a va 2 s .c o m*/ public void testResultSetWhenClosed() throws Exception { Statement statement = getConnection().createStatement(); ResultSet rs = statement.executeQuery(SQL_EMPS); rs.close(); try { rs.isBeforeFirst(); fail(); } catch (SQLException ignore) { } try { rs.isAfterLast(); fail(); } catch (SQLException ignore) { } try { rs.isFirst(); fail(); } catch (SQLException ignore) { } try { rs.isLast(); fail(); } catch (SQLException ignore) { } try { rs.beforeFirst(); fail(); } catch (SQLException ignore) { } try { rs.afterLast(); fail(); } catch (SQLException ignore) { } try { rs.first(); fail(); } catch (SQLException ignore) { } try { rs.last(); fail(); } catch (SQLException ignore) { } try { rs.next(); fail(); } catch (SQLException ignore) { } try { rs.getRow(); fail(); } catch (SQLException ignore) { } try { rs.getType(); fail(); } catch (SQLException ignore) { } try { rs.getConcurrency(); fail(); } catch (SQLException ignore) { } try { rs.rowUpdated(); fail(); } catch (SQLException ignore) { } try { rs.rowDeleted(); fail(); } catch (SQLException ignore) { } try { rs.rowInserted(); fail(); } catch (SQLException ignore) { } try { rs.getStatement(); fail(); } catch (SQLException ignore) { } try { rs.wasNull(); fail(); } catch (SQLException ignore) { } try { rs.getString(1); fail(); } catch (SQLException ignore) { } try { rs.getString("col1"); fail(); } catch (SQLException ignore) { } try { rs.getBoolean(1); fail(); } catch (SQLException ignore) { } try { rs.getBoolean("col1"); fail(); } catch (SQLException ignore) { } try { rs.getByte(1); fail(); } catch (SQLException ignore) { } try { rs.getByte("col1"); fail(); } catch (SQLException ignore) { } try { rs.getShort(1); fail(); } catch (SQLException ignore) { } try { rs.getShort("col1"); fail(); } catch (SQLException ignore) { } try { rs.getInt(1); fail(); } catch (SQLException ignore) { } try { rs.getInt("col1"); fail(); } catch (SQLException ignore) { } try { rs.getLong(1); fail(); } catch (SQLException ignore) { } try { rs.getLong("col1"); fail(); } catch (SQLException ignore) { } try { rs.getFloat(1); fail(); } catch (SQLException ignore) { } try { rs.getFloat("col1"); fail(); } catch (SQLException ignore) { } try { rs.getDouble(1); fail(); } catch (SQLException ignore) { } try { rs.getDouble("col1"); fail(); } catch (SQLException ignore) { } try { rs.getBigDecimal(1); fail(); } catch (SQLException ignore) { } try { rs.getBigDecimal("col1"); fail(); } catch (SQLException ignore) { } try { rs.getBytes(1); fail(); } catch (SQLException ignore) { } try { rs.getBytes("col1"); fail(); } catch (SQLException ignore) { } try { rs.getDate(1); fail(); } catch (SQLException ignore) { } try { rs.getDate(1, null); fail(); } catch (SQLException ignore) { } try { rs.getDate("col1"); fail(); } catch (SQLException ignore) { } try { rs.getDate("col1", null); fail(); } catch (SQLException ignore) { } try { rs.getTime(1); fail(); } catch (SQLException ignore) { } try { rs.getTime(1, null); fail(); } catch (SQLException ignore) { } try { rs.getTime("col1"); fail(); } catch (SQLException ignore) { } try { rs.getTime("col1", null); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp(1); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp(1, null); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp("col1"); fail(); } catch (SQLException ignore) { } try { rs.getTimestamp("col1", null); fail(); } catch (SQLException ignore) { } try { rs.getAsciiStream(1); fail(); } catch (SQLException ignore) { } try { rs.getAsciiStream("col1"); fail(); } catch (SQLException ignore) { } try { rs.getUnicodeStream(1); fail(); } catch (SQLException ignore) { } try { rs.getUnicodeStream("col1"); fail(); } catch (SQLException ignore) { } try { rs.getBinaryStream(1); fail(); } catch (SQLException ignore) { } try { rs.getBinaryStream("col1"); fail(); } catch (SQLException ignore) { } try { rs.getCharacterStream(1); fail(); } catch (SQLException ignore) { } try { rs.getCharacterStream("col1"); fail(); } catch (SQLException ignore) { } try { rs.getMetaData(); fail(); } catch (SQLException ignore) { } try { rs.setFetchDirection(1); fail(); } catch (SQLException ignore) { } try { rs.getFetchDirection(); fail(); } catch (SQLException ignore) { } try { rs.setFetchSize(100); fail(); } catch (SQLException ignore) { } try { rs.getFetchSize(); fail(); } catch (SQLException ignore) { } try { rs.getHoldability(); fail(); } catch (SQLException ignore) { } statement.close(); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java
protected CFAccAccountEntryBuff unpackAccountEntryResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountEntryResultSetToBuff"; int idxcol = 1; CFAccAccountEntryBuff buff = schema.getFactoryAccountEntry().newBuff(); {/*from w ww . j a va 2s .c o m*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccDb2LUWSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredEntryId(CFAccDb2LUWSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; { UUID colVal = CFAccDb2LUWSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalSplitEntryId(null); } else { buff.setOptionalSplitEntryId(colVal); } } idxcol++; buff.setRequiredEntryStamp(CFAccDb2LUWSchema.convertTimestampString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferTenantId(null); } else { buff.setOptionalTransferTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferAccountId(null); } else { buff.setOptionalTransferAccountId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebitCurrencyId(null); } else { buff.setOptionalDebitCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebit(null); } else { buff.setOptionalDebit(bival); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCreditCurrencyId(null); } else { buff.setOptionalCreditCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalCredit(null); } else { buff.setOptionalCredit(bival); } } idxcol++; buff.setRequiredConvertedCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredConvertedAmount(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredBalanceCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAccountEntryTable.java
protected CFAccAccountEntryBuff unpackAccountEntryResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountEntryResultSetToBuff"; int idxcol = 1; CFAccAccountEntryBuff buff = schema.getFactoryAccountEntry().newBuff(); {//from ww w .ja va 2s . com String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredEntryId(CFAccPgSqlSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; { UUID colVal = CFAccPgSqlSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalSplitEntryId(null); } else { buff.setOptionalSplitEntryId(colVal); } } idxcol++; buff.setRequiredEntryStamp(CFAccPgSqlSchema.convertTimestampString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferTenantId(null); } else { buff.setOptionalTransferTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferAccountId(null); } else { buff.setOptionalTransferAccountId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebitCurrencyId(null); } else { buff.setOptionalDebitCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebit(null); } else { buff.setOptionalDebit(bival); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCreditCurrencyId(null); } else { buff.setOptionalCreditCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalCredit(null); } else { buff.setOptionalCredit(bival); } } idxcol++; buff.setRequiredConvertedCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredConvertedAmount(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredBalanceCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlAccountEntryTable.java
protected CFAccAccountEntryBuff unpackAccountEntryResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountEntryResultSetToBuff"; int idxcol = 1; CFAccAccountEntryBuff buff = schema.getFactoryAccountEntry().newBuff(); {/*from w w w.j a v a 2 s . c om*/ String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccMySqlSchema.convertTimestampString(colString)); } } idxcol++; { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } } idxcol++; buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredEntryId(CFAccMySqlSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; { UUID colVal = CFAccMySqlSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalSplitEntryId(null); } else { buff.setOptionalSplitEntryId(colVal); } } idxcol++; buff.setRequiredEntryStamp(CFAccMySqlSchema.convertTimestampString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferTenantId(null); } else { buff.setOptionalTransferTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferAccountId(null); } else { buff.setOptionalTransferAccountId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebitCurrencyId(null); } else { buff.setOptionalDebitCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebit(null); } else { buff.setOptionalDebit(bival); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCreditCurrencyId(null); } else { buff.setOptionalCreditCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalCredit(null); } else { buff.setOptionalCredit(bival); } } idxcol++; buff.setRequiredConvertedCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredConvertedAmount(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredBalanceCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAccountEntryTable.java
protected CFAccAccountEntryBuff unpackAccountEntryResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountEntryResultSetToBuff"; int idxcol = 1; CFAccAccountEntryBuff buff = schema.getFactoryAccountEntry().newBuff(); {//from w ww . j av a 2 s. c o m String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccMSSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccMSSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredEntryId(CFAccMSSqlSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; { UUID colVal = CFAccMSSqlSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalSplitEntryId(null); } else { buff.setOptionalSplitEntryId(colVal); } } idxcol++; buff.setRequiredEntryStamp(CFAccMSSqlSchema.convertTimestampString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferTenantId(null); } else { buff.setOptionalTransferTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferAccountId(null); } else { buff.setOptionalTransferAccountId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebitCurrencyId(null); } else { buff.setOptionalDebitCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebit(null); } else { buff.setOptionalDebit(bival); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCreditCurrencyId(null); } else { buff.setOptionalCreditCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalCredit(null); } else { buff.setOptionalCredit(bival); } } idxcol++; buff.setRequiredConvertedCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredConvertedAmount(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredBalanceCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountEntryTable.java
protected CFAccAccountEntryBuff unpackAccountEntryResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountEntryResultSetToBuff"; int idxcol = 1; CFAccAccountEntryBuff buff = schema.getFactoryAccountEntry().newBuff(); {//from ww w . j av a 2 s . c o m String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccOracleSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccOracleSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredAccountId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredEntryId(CFAccOracleSchema.convertUuidString(resultSet.getString(idxcol))); idxcol++; { UUID colVal = CFAccOracleSchema.convertUuidString(resultSet.getString(idxcol)); if (resultSet.wasNull()) { buff.setOptionalSplitEntryId(null); } else { buff.setOptionalSplitEntryId(colVal); } } idxcol++; buff.setRequiredEntryStamp(CFAccOracleSchema.convertTimestampString(resultSet.getString(idxcol))); idxcol++; buff.setRequiredDescription(resultSet.getString(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferTenantId(null); } else { buff.setOptionalTransferTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalTransferAccountId(null); } else { buff.setOptionalTransferAccountId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebitCurrencyId(null); } else { buff.setOptionalDebitCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalDebit(null); } else { buff.setOptionalDebit(bival); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalCreditCurrencyId(null); } else { buff.setOptionalCreditCurrencyId(colVal); } } idxcol++; { BigDecimal bival = resultSet.getBigDecimal(idxcol); if (resultSet.wasNull()) { buff.setOptionalCredit(null); } else { buff.setOptionalCredit(bival); } } idxcol++; buff.setRequiredConvertedCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredConvertedAmount(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredBalanceCurrencyId(resultSet.getShort(idxcol)); idxcol++; buff.setRequiredBalance(resultSet.getBigDecimal(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); }
From source file:com.mimp.hibernate.HiberEtapa.java
public ArrayList<Familia> getListaFamilias() { Session session = sessionFactory.getCurrentSession(); session.beginTransaction();/*from w w w . ja v a 2 s.com*/ final ArrayList<Familia> allFamilias = new ArrayList(); Work work = new Work() { @Override public void execute(Connection connection) throws SQLException { ExpedienteNna expnna; String hql = "{call HE_FAM_HAB(?)}"; CallableStatement statement = connection.prepareCall(hql); statement.registerOutParameter(1, OracleTypes.CURSOR); statement.execute(); ResultSet rs = (ResultSet) statement.getObject(1); while (rs.next()) { Set<ExpedienteFamilia> listExp = new HashSet<ExpedienteFamilia>(); Set<AsistenciaFR> listAFR = new HashSet<AsistenciaFR>(); Set<FormularioSesion> listFS = new HashSet<FormularioSesion>(); Familia tempFamp = new Familia(); tempFamp.setIdfamilia(rs.getLong("IDFAMILIA")); tempFamp.setCorreo(rs.getString("CORREO")); tempFamp.setHabilitado(rs.getShort("HABILITADO")); tempFamp.setConstancia(rs.getString("CONSTANCIA")); String hql2 = "{call HE_GET_EXPFAM_BY_IDFAM(?,?)}"; CallableStatement statement2 = connection.prepareCall(hql2); statement2.setLong(1, tempFamp.getIdfamilia()); statement2.registerOutParameter(2, OracleTypes.CURSOR); statement2.execute(); ResultSet rs2 = (ResultSet) statement2.getObject(2); if (rs2.next()) { ExpedienteFamilia tempExpFam = new ExpedienteFamilia(); tempExpFam.setIdexpedienteFamilia(rs2.getLong("IDEXPEDIENTE_FAMILIA")); tempExpFam.setExpediente(rs2.getString("EXPEDIENTE")); tempExpFam.setHt(rs2.getString("HT")); listExp.add(tempExpFam); } rs2.close(); statement2.close(); String hql3 = "{call HE_AFR_BY_IDFAM(?,?)}"; CallableStatement statement3 = connection.prepareCall(hql3); statement3.setLong(1, tempFamp.getIdfamilia()); statement3.registerOutParameter(2, OracleTypes.CURSOR); statement3.execute(); ResultSet rs3 = (ResultSet) statement3.getObject(2); while (rs3.next()) { AsistenciaFR tempAFR = new AsistenciaFR(); tempAFR.setIdasistenciaFR(rs3.getLong("IDASISTENCIA_F_R")); String asist = ""; asist = rs3.getString("ASISTENCIA"); if (!rs3.wasNull()) { tempAFR.setAsistencia(asist.charAt(0)); } tempAFR.setInasJus(rs3.getShort("INAS_JUS")); tempAFR.setFamilia(tempFamp); listAFR.add(tempAFR); } rs3.close(); statement3.close(); String hql4 = "{call HE_GET_FS_BY_IDFAM(?,?)}"; CallableStatement statement4 = connection.prepareCall(hql4); statement4.setLong(1, tempFamp.getIdfamilia()); statement4.registerOutParameter(2, OracleTypes.CURSOR); statement4.execute(); ResultSet rs4 = (ResultSet) statement4.getObject(2); if (rs4.next()) { FormularioSesion tempFS = new FormularioSesion(); Sesion tempSesion = new Sesion(); tempFS.setIdformularioSesion(rs4.getLong("IDFORMULARIO_SESION")); tempSesion.setIdsesion(rs4.getLong("IDSESION")); tempSesion.setUnidad(rs4.getString("UNIDAD")); Set<Asistente> listA = new HashSet<Asistente>(); String hql5 = "{call HE_GET_ASIS_BY_IDFS(?,?)}"; CallableStatement statement5 = connection.prepareCall(hql5); statement5.setLong(1, tempFS.getIdformularioSesion()); statement5.registerOutParameter(2, OracleTypes.CURSOR); statement5.execute(); ResultSet rs5 = (ResultSet) statement5.getObject(2); while (rs5.next()) { Asistente tempAsis = new Asistente(); tempAsis.setIdasistente(rs5.getLong("IDASISTENTE")); tempAsis.setNombre(rs5.getString("NOMBRE")); tempAsis.setApellidoP(rs5.getString("APELLIDO_P")); tempAsis.setApellidoM(rs5.getString("APELLIDO_M")); String tempsexo = ""; tempsexo = rs5.getString("SEXO"); if (!rs5.wasNull()) { tempAsis.setSexo(tempsexo.charAt(0)); } tempAsis.setEdad(rs5.getShort("EDAD")); tempAsis.setCorreo(rs5.getString("CORREO")); tempAsis.setFormularioSesion(tempFS); listA.add(tempAsis); } rs5.close(); statement5.close(); tempFS.setSesion(tempSesion); tempFS.setAsistentes(listA); listFS.add(tempFS); } rs4.close(); statement4.close(); tempFamp.setExpedienteFamilias(listExp); tempFamp.setAsistenciaFRs(listAFR); tempFamp.setFormularioSesions(listFS); allFamilias.add(tempFamp); } rs.close(); statement.close(); } }; session.doWork(work); return allFamilias; }