List of usage examples for java.sql Types NUMERIC
int NUMERIC
To view the source code for java.sql Types NUMERIC.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type NUMERIC
.
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountEntryTable.java
public void createAccountEntry(CFAccAuthorization Authorization, CFAccAccountEntryBuff Buff) { final String S_ProcName = "createAccountEntry"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*www.j av a 2 s.c om*/ ResultSet resultSet = null; CallableStatement stmtCreateByPKey = null; try { long TenantId = Buff.getRequiredTenantId(); long AccountId = Buff.getRequiredAccountId(); UUID SplitEntryId = Buff.getOptionalSplitEntryId(); Calendar EntryStamp = Buff.getRequiredEntryStamp(); String Description = Buff.getRequiredDescription(); Long TransferTenantId = Buff.getOptionalTransferTenantId(); Long TransferAccountId = Buff.getOptionalTransferAccountId(); Short DebitCurrencyId = Buff.getOptionalDebitCurrencyId(); BigDecimal Debit = Buff.getOptionalDebit(); Short CreditCurrencyId = Buff.getOptionalCreditCurrencyId(); BigDecimal Credit = Buff.getOptionalCredit(); short ConvertedCurrencyId = Buff.getRequiredConvertedCurrencyId(); BigDecimal ConvertedAmount = Buff.getRequiredConvertedAmount(); short BalanceCurrencyId = Buff.getRequiredBalanceCurrencyId(); BigDecimal Balance = Buff.getRequiredBalance(); UUID EntryId = UUID.randomUUID(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName() + ".crt_ac_entry( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "to_timestamp( ?, 'YYYY-MM-DD HH24:MI:SS' )" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "ACNY"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setLong(argIdx++, AccountId); stmtCreateByPKey.setString(argIdx++, EntryId.toString()); if (SplitEntryId != null) { stmtCreateByPKey.setString(argIdx++, SplitEntryId.toString()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setString(argIdx++, CFAccOracleSchema.getTimestampString(EntryStamp)); stmtCreateByPKey.setString(argIdx++, Description); if (TransferTenantId != null) { stmtCreateByPKey.setLong(argIdx++, TransferTenantId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (TransferAccountId != null) { stmtCreateByPKey.setLong(argIdx++, TransferAccountId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (DebitCurrencyId != null) { stmtCreateByPKey.setShort(argIdx++, DebitCurrencyId.shortValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } if (Debit != null) { stmtCreateByPKey.setBigDecimal(argIdx++, Debit); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.NUMERIC); } if (CreditCurrencyId != null) { stmtCreateByPKey.setShort(argIdx++, CreditCurrencyId.shortValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT); } if (Credit != null) { stmtCreateByPKey.setBigDecimal(argIdx++, Credit); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.NUMERIC); } stmtCreateByPKey.setShort(argIdx++, ConvertedCurrencyId); stmtCreateByPKey.setBigDecimal(argIdx++, ConvertedAmount); stmtCreateByPKey.setShort(argIdx++, BalanceCurrencyId); stmtCreateByPKey.setBigDecimal(argIdx++, Balance); stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_ac_entry() did not return a result set"); } try { if (resultSet.next()) { CFAccAccountEntryBuff createdBuff = unpackAccountEntryResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredAccountId(createdBuff.getRequiredAccountId()); Buff.setRequiredEntryId(createdBuff.getRequiredEntryId()); Buff.setOptionalSplitEntryId(createdBuff.getOptionalSplitEntryId()); Buff.setRequiredEntryStamp(createdBuff.getRequiredEntryStamp()); Buff.setRequiredDescription(createdBuff.getRequiredDescription()); Buff.setOptionalTransferTenantId(createdBuff.getOptionalTransferTenantId()); Buff.setOptionalTransferAccountId(createdBuff.getOptionalTransferAccountId()); Buff.setOptionalDebitCurrencyId(createdBuff.getOptionalDebitCurrencyId()); Buff.setOptionalDebit(createdBuff.getOptionalDebit()); Buff.setOptionalCreditCurrencyId(createdBuff.getOptionalCreditCurrencyId()); Buff.setOptionalCredit(createdBuff.getOptionalCredit()); Buff.setRequiredConvertedCurrencyId(createdBuff.getRequiredConvertedCurrencyId()); Buff.setRequiredConvertedAmount(createdBuff.getRequiredConvertedAmount()); Buff.setRequiredBalanceCurrencyId(createdBuff.getRequiredBalanceCurrencyId()); Buff.setRequiredBalance(createdBuff.getRequiredBalance()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_ac_entry() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:org.apache.ddlutils.model.Column.java
/** * Tries to parse the default value of the column and returns it as an object of the * corresponding java type. If the value could not be parsed, then the original * definition is returned./*from w w w. ja v a2 s. c o m*/ * * @return The parsed default value */ public Object getParsedDefaultValue() { if ((_defaultValue != null) && (_defaultValue.length() > 0)) { try { switch (_typeCode) { case Types.TINYINT: case Types.SMALLINT: return new Short(_defaultValue); case Types.INTEGER: return new Integer(_defaultValue); case Types.BIGINT: return new Long(_defaultValue); case Types.DECIMAL: case Types.NUMERIC: return new BigDecimal(_defaultValue); case Types.REAL: return new Float(_defaultValue); case Types.DOUBLE: case Types.FLOAT: return new Double(_defaultValue); case Types.DATE: return Date.valueOf(_defaultValue); case Types.TIME: return Time.valueOf(_defaultValue); case Types.TIMESTAMP: return Timestamp.valueOf(_defaultValue); case Types.BIT: case Types.BOOLEAN: return ConvertUtils.convert(_defaultValue, Boolean.class); } } catch (NumberFormatException ex) { return null; } catch (IllegalArgumentException ex) { return null; } } return _defaultValue; }
From source file:nl.nn.adapterframework.statistics.jdbc.StatisticsKeeperStore.java
public void handleStatisticsKeeper(Object data, StatisticsKeeper sk) throws SenderException { SessionInfo sessionInfo = (SessionInfo) data; PreparedStatement stmt = null; int statnamekey = -1; try {/*from w ww . j ava2 s.c om*/ statnamekey = statnames.findOrInsert(sessionInfo.connection, sk.getName()); if (trace && log.isDebugEnabled()) log.debug("prepare and execute query [" + insertStatKeeperQuery + "]"); stmt = sessionInfo.connection.prepareStatement(insertStatKeeperQuery); int pos = 1; long count = sk.getCount(); applyParam(stmt, pos++, sessionInfo.eventKey); applyParam(stmt, pos++, sessionInfo.groupKey); applyParam(stmt, pos++, statnamekey); applyParam(stmt, pos++, count); if (count == 0) { stmt.setNull(pos++, Types.NUMERIC); stmt.setNull(pos++, Types.NUMERIC); stmt.setNull(pos++, Types.NUMERIC); stmt.setNull(pos++, Types.NUMERIC); } else { applyParam(stmt, pos++, sk.getMin()); applyParam(stmt, pos++, sk.getMax()); applyParam(stmt, pos++, sk.getAvg()); if (count == 1) { stmt.setNull(pos++, Types.NUMERIC); } else { applyParam(stmt, pos++, sk.getStdDev()); } } applyParam(stmt, pos++, sk.getTotal()); applyParam(stmt, pos++, sk.getTotalSquare()); stmt.execute(); } catch (Exception e) { throw new SenderException("could not execute query [" + insertStatKeeperQuery + "]", e); } finally { if (stmt != null) { try { stmt.close(); } catch (Exception e) { throw new SenderException("could not close statement for query [" + insertStatKeeperQuery + "]", e); } } } }
From source file:org.jumpmind.symmetric.db.derby.DerbyFunctions.java
public static String getPrimaryKeyWhereString(String[] pkColumnNames, ResultSet rs) throws SQLException { final String AND = " and "; ResultSetMetaData metaData = rs.getMetaData(); StringBuilder b = new StringBuilder(); for (int i = 0; i < pkColumnNames.length; i++) { String columnName = pkColumnNames[i]; int index = findColumnIndex(metaData, columnName); int type = metaData.getColumnType(index); if (type != Types.BINARY && type != Types.BLOB && type != Types.LONGVARBINARY && type != Types.VARBINARY) { b.append("\"").append(columnName).append("\"="); switch (type) { case Types.BIT: case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: case Types.BIGINT: case Types.FLOAT: case Types.REAL: case Types.DOUBLE: case Types.NUMERIC: case Types.DECIMAL: case Types.BOOLEAN: b.append(rs.getObject(index)); break; case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: b.append("\"").append(rs.getString(index)).append("\""); break; case Types.DATE: case Types.TIMESTAMP: b.append("{ts '"); b.append(rs.getString(index)); b.append("'}"); break; }/* www . j ava2 s . com*/ b.append(AND); } } b.replace(b.length() - AND.length(), b.length(), ""); return b.toString(); }
From source file:com.nextep.designer.sqlclient.ui.connectors.SQLResultConnector.java
private void initializeTable(ISQLQuery query, long executionTime, INextepMetadata md) { colMaxWidth = new int[md.getColumnCount() + 1]; // Checking columns to display int displayedColumns = query.getDisplayedColumnsCount(); if (displayedColumns <= 0) { displayedColumns = md.getColumnCount(); }// w w w . ja v a 2 s. c o m for (int i = 1; i <= displayedColumns; i++) { final String colName = md.getColumnName(i); // final int colPrecision = md.getPrecision(index); final int colType = md.getColumnType(i); final int colIndex = i - 1; if (!sqlView.isDisposed()) { TableColumn c = new TableColumn(sqlView, SWT.NONE); c.setText(colName); c.setWidth(colName.length() * 8); c.addListener(SWT.Selection, comparator); colMaxWidth[colIndex] = c.getWidth(); SQLResultLabelProvider lblProvider = new SQLResultLabelProvider(this, colIndex); final TableViewerColumn viewerCol = new TableViewerColumn(sqlViewer, c); viewerCol.setLabelProvider(lblProvider); // Registering column comparator switch (colType) { case Types.BIGINT: case Types.BIT: case Types.DECIMAL: case Types.DOUBLE: case Types.FLOAT: case Types.INTEGER: case Types.NUMERIC: case Types.REAL: case Types.SMALLINT: case Types.TINYINT: c.setData(SQLResultViewerComparator.KEY_COMPARATOR, new NumberComparator()); // Setting our deserializer which can produce number from string c.setData(KEY_DESERIALIZER, NUMBER_DESERIALIZER); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: // Defines validation so that user will be notified about problems c.setData(KEY_CELL_VALIDATOR, DATE_VALIDATOR); // Setting our deserializer which can produce date from string c.setData(KEY_DESERIALIZER, DATE_DESERIALIZER); c.setData(SQLResultViewerComparator.KEY_COMPARATOR, new DateComparator()); break; default: c.setData(KEY_DESERIALIZER, STRING_DESERIALIZER); c.setData(SQLResultViewerComparator.KEY_COMPARATOR, new StringComparator()); } } } registerCellEditors(); setStatusLabel(MessageFormat.format(SQLClientMessages.getString("sql.executionTime"), executionTime), false); sqlViewer.setInput(query.getResult()); }
From source file:org.springframework.jdbc.object.SqlUpdateTests.java
public void testUpdateConstructor() throws SQLException { mockPreparedStatement.setObject(1, new Integer(1), Types.NUMERIC); mockPreparedStatement.setObject(2, new Integer(1), Types.NUMERIC); mockPreparedStatement.setString(3, "rod"); mockPreparedStatement.setObject(4, Boolean.TRUE, Types.BOOLEAN); ctrlPreparedStatement.setVoidCallable(); mockPreparedStatement.executeUpdate(); ctrlPreparedStatement.setReturnValue(1); if (debugEnabled) { mockPreparedStatement.getWarnings(); ctrlPreparedStatement.setReturnValue(null); }/*from w ww . ja v a 2 s . co m*/ mockPreparedStatement.close(); ctrlPreparedStatement.setVoidCallable(); mockConnection.prepareStatement(UPDATE_OBJECTS); ctrlConnection.setReturnValue(mockPreparedStatement); replay(); ConstructorUpdater pc = new ConstructorUpdater(); int rowsAffected = pc.run(1, 1, "rod", true); assertEquals(1, rowsAffected); }
From source file:org.hibernate.dialect.Dialect.java
protected Dialect() { log.info("Using dialect: " + this); sqlFunctions.putAll(STANDARD_AGGREGATE_FUNCTIONS); // standard sql92 functions (can be overridden by subclasses) registerFunction("substring", new SQLFunctionTemplate(Hibernate.STRING, "substring(?1, ?2, ?3)")); registerFunction("locate", new SQLFunctionTemplate(Hibernate.INTEGER, "locate(?1, ?2, ?3)")); registerFunction("trim", new SQLFunctionTemplate(Hibernate.STRING, "trim(?1 ?2 ?3 ?4)")); registerFunction("length", new StandardSQLFunction("length", Hibernate.INTEGER)); registerFunction("bit_length", new StandardSQLFunction("bit_length", Hibernate.INTEGER)); registerFunction("coalesce", new StandardSQLFunction("coalesce")); registerFunction("nullif", new StandardSQLFunction("nullif")); registerFunction("abs", new StandardSQLFunction("abs")); registerFunction("mod", new StandardSQLFunction("mod", Hibernate.INTEGER)); registerFunction("sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE)); registerFunction("upper", new StandardSQLFunction("upper")); registerFunction("lower", new StandardSQLFunction("lower")); registerFunction("cast", new CastFunction()); registerFunction("extract", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(?1 ?2 ?3)")); //map second/minute/hour/day/month/year to ANSI extract(), override on subclasses registerFunction("second", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(second from ?1)")); registerFunction("minute", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(minute from ?1)")); registerFunction("hour", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(hour from ?1)")); registerFunction("day", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(day from ?1)")); registerFunction("month", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(month from ?1)")); registerFunction("year", new SQLFunctionTemplate(Hibernate.INTEGER, "extract(year from ?1)")); registerFunction("str", new SQLFunctionTemplate(Hibernate.STRING, "cast(?1 as char)")); // register hibernate types for default use in scalar sqlquery type auto detection registerHibernateType(Types.BIGINT, Hibernate.BIG_INTEGER.getName()); registerHibernateType(Types.BINARY, Hibernate.BINARY.getName()); registerHibernateType(Types.BIT, Hibernate.BOOLEAN.getName()); registerHibernateType(Types.CHAR, Hibernate.CHARACTER.getName()); registerHibernateType(Types.DATE, Hibernate.DATE.getName()); registerHibernateType(Types.DOUBLE, Hibernate.DOUBLE.getName()); registerHibernateType(Types.FLOAT, Hibernate.FLOAT.getName()); registerHibernateType(Types.INTEGER, Hibernate.INTEGER.getName()); registerHibernateType(Types.SMALLINT, Hibernate.SHORT.getName()); registerHibernateType(Types.TINYINT, Hibernate.BYTE.getName()); registerHibernateType(Types.TIME, Hibernate.TIME.getName()); registerHibernateType(Types.TIMESTAMP, Hibernate.TIMESTAMP.getName()); registerHibernateType(Types.VARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.VARBINARY, Hibernate.BINARY.getName()); registerHibernateType(Types.NUMERIC, Hibernate.BIG_DECIMAL.getName()); registerHibernateType(Types.DECIMAL, Hibernate.BIG_DECIMAL.getName()); registerHibernateType(Types.BLOB, Hibernate.BLOB.getName()); registerHibernateType(Types.CLOB, Hibernate.CLOB.getName()); registerHibernateType(Types.REAL, Hibernate.FLOAT.getName()); }
From source file:com.squid.core.domain.operators.ExtendedType.java
private String getTypeName(int SQLType) { switch (SQLType) { case Types.ARRAY: return "ARRAY"; case Types.BIGINT: return "INTEGER"; case Types.BINARY: return "BINARY"; case Types.BIT: return "BIT"; case Types.BLOB: return "BLOB"; case Types.BOOLEAN: return "BOOLEAN"; case Types.CHAR: return "CHAR"; case Types.CLOB: return "CLOB"; case Types.DATALINK: return "DATALINK"; case Types.DATE: return "DATE"; case Types.DECIMAL: return "DECIMAL"; case Types.DOUBLE: return "DOUBLE"; case Types.FLOAT: return "FLOAT"; case Types.INTEGER: return "INTEGER"; case Types.JAVA_OBJECT: return "JAVA_OBJECT"; case Types.LONGNVARCHAR: return "LONGNVARCHAR"; case Types.LONGVARBINARY: return "LONGVARBINARY"; case Types.NCHAR: return "NCHAR"; case Types.NCLOB: return "NCLOB"; case Types.NULL: return "UNDEFINED";// case Types.NUMERIC: return "NUMERIC"; case Types.NVARCHAR: return "NVARCHAR"; case Types.OTHER: return "UNDEFINED";// case Types.REAL: return "REAL"; case Types.REF: return "REF"; case Types.ROWID: return "ROWID"; case Types.SMALLINT: return "SMALLINT"; case Types.SQLXML: return "SQLXML"; case Types.STRUCT: return "STRUCT"; case Types.TIME: return "TIME"; case Types.TIMESTAMP: return "TIMESTAMP"; case Types.TINYINT: return "TINYINT"; case Types.VARBINARY: return "VARBINARY"; case Types.VARCHAR: return "VARCHAR"; default://from w w w.j ava 2s. co m return "UNDEFINED";// } }
From source file:com.flexive.ejb.beans.workflow.StepDefinitionEngineBean.java
/** * {@inheritDoc}// ww w.j a v a 2s . co m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void update(StepDefinition stepDefinition) throws FxApplicationException { final UserTicket ticket = FxContext.getUserTicket(); final FxContext ri = FxContext.get(); // Security checks FxPermissionUtils.checkRole(ticket, Role.WorkflowManagement); StepDefinition orgDefinition; try { // Lookup the stepDefinition, throws FxNotFoundException (+FxDbException) orgDefinition = getEnvironment().getStepDefinition(stepDefinition.getId()); } catch (Exception exc) { throw new FxUpdateException(exc.getMessage(), exc); } // Unique target checks boolean uniqueTargetAdded = stepDefinition.getId() != -1 && stepDefinition.getUniqueTargetId() != -1 && stepDefinition.getUniqueTargetId() != orgDefinition.getUniqueTargetId(); // Check the unique target, throws FxInvalidParameterException if target is invalid (+FxDbException) if (stepDefinition.getUniqueTargetId() != -1) { checkValidUniqueTarget(stepDefinition.getId(), stepDefinition.getUniqueTargetId()); } // Sanity checks if (stepDefinition.getLabel() == null || stepDefinition.getLabel().isEmpty()) { throw new FxInvalidParameterException("NAME", "ex.stepdefinition.name.empty"); } Connection con = null; PreparedStatement stmt = null; String sql; boolean success = false; try { // Obtain a database connection con = Database.getDbConnection(); // store label Database.storeFxString(stepDefinition.getLabel(), con, TBL_WORKFLOW_STEPDEFINITION, "name", "id", stepDefinition.getId()); sql = "UPDATE " + TBL_WORKFLOW_STEPDEFINITION + " SET NAME=?,UNIQUE_TARGET=? WHERE ID=?"; stmt = con.prepareStatement(sql); stmt.setString(1, stepDefinition.getName()); if (stepDefinition.getUniqueTargetId() != -1) { stmt.setLong(2, stepDefinition.getUniqueTargetId()); } else { stmt.setNull(2, Types.NUMERIC); } stmt.setLong(3, stepDefinition.getId()); int updateCount = stmt.executeUpdate(); if (updateCount == 0) { FxNotFoundException nfe = new FxNotFoundException("ex.stepdefinition.load.notFound", stepDefinition.getId()); if (LOG.isInfoEnabled()) LOG.info(nfe); throw nfe; } else if (updateCount != 1) { FxUpdateException dbe = new FxUpdateException("ex.stepdefinition.update.rows"); LOG.error(dbe); throw dbe; } // Unique target has to exist for every workflow long workflowId; if (uniqueTargetAdded) { try { ri.runAsSystem(); List<StepDefinition> stepDefinitionList = new ArrayList<StepDefinition>(); stepDefinitionList.add(stepDefinition); // Do this for all existing workflows .. for (Workflow workflow : getEnvironment().getWorkflows()) { workflowId = workflow.getId(); if (FxSharedUtils.getUsedStepDefinitions(workflow.getSteps(), stepDefinitionList) .size() > 0) { // create step IF the step definition is used by the workflow stepEngine.createStep( new Step(-1, stepDefinition.getUniqueTargetId(), workflowId, getEnvironment() .getStepByDefinition(workflowId, stepDefinition.getId()).getAclId())); } } } catch (Exception exc) { throw new FxUpdateException(LOG, "ex.stepdefinition.uniqueTarget.create"); } finally { ri.stopRunAsSystem(); } } success = true; } catch (SQLException exc) { if (StorageManager.isUniqueConstraintViolation(exc)) { FxEntryExistsException ee = new FxEntryExistsException("ex.stepdefinition.name.exists", stepDefinition.getName()); if (LOG.isDebugEnabled()) LOG.debug(ee); throw ee; } throw new FxUpdateException(LOG, exc, "ex.db.sqlError", exc.getMessage()); } finally { Database.closeObjects(StepDefinitionEngineBean.class, con, stmt); if (!success) { EJBUtils.rollback(ctx); } else { StructureLoader.reloadWorkflows(FxContext.get().getDivisionId()); } } }
From source file:oscar.util.SqlUtils.java
private static Object getNewType(ResultSet rs, int colNum) { int type = 0; try {/* w ww .j ava 2 s .c om*/ type = rs.getMetaData().getColumnType(colNum); switch (type) { case Types.LONGVARCHAR: case Types.CHAR: case Types.VARCHAR: return oscar.Misc.getString(rs, colNum); case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: return new Integer(rs.getInt(colNum)); case Types.BIGINT: return new Long(rs.getLong(colNum)); case Types.FLOAT: case Types.DECIMAL: case Types.REAL: case Types.DOUBLE: case Types.NUMERIC: return new Double(rs.getDouble(colNum)); // case Types.B case Types.BIT: return new Boolean(rs.getBoolean(colNum)); case Types.TIMESTAMP: case Types.DATE: case Types.TIME: return rs.getDate(colNum); default: return rs.getObject(colNum); } } catch (Exception e) { MiscUtils.getLogger().error("Error", e); } return null; }