List of usage examples for java.sql Types INTEGER
int INTEGER
To view the source code for java.sql Types INTEGER.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER
.
From source file:com.mobiaware.auction.data.impl.MySqlDataServiceImpl.java
@Override public int editAuction(final Auction auction) { int uid = -1; Connection conn = null;//from w w w . j a va 2 s. c om CallableStatement stmt = null; ResultSet rs = null; try { conn = _dataSource.getConnection(); stmt = conn.prepareCall("{call SP_EDITAUCTION (?,?,?,?,?,?)}"); stmt.registerOutParameter(1, Types.INTEGER); stmt.setString(2, auction.getName()); stmt.setDate(3, new Date(auction.getStartDate())); stmt.setDate(4, new Date(auction.getEndDate())); stmt.setString(5, auction.getLogoUrl()); stmt.setString(6, auction.getColor()); stmt.execute(); uid = stmt.getInt(1); } catch (SQLException e) { LOG.error(Throwables.getStackTraceAsString(e)); } finally { DbUtils.closeQuietly(conn, stmt, rs); } if (LOG.isDebugEnabled()) { LOG.debug("AUCTION [method:{} result:{}]", new Object[] { "edit", uid }); } return uid; }
From source file:com.act.lcms.db.model.Plate.java
protected static void bindInsertOrUpdateParameters(PreparedStatement stmt, String name, String description, String barcode, String location, String plateType, String solvent, Integer temperature, CONTENT_TYPE contentType) throws SQLException { stmt.setString(DB_FIELD.NAME.getInsertUpdateOffset(), trimAndComplain(name)); if (description != null) { stmt.setString(DB_FIELD.DESCRIPTION.getInsertUpdateOffset(), trimAndComplain(description)); } else {//w w w . ja v a 2s.c o m stmt.setNull(DB_FIELD.DESCRIPTION.getInsertUpdateOffset(), Types.VARCHAR); } if (barcode != null) { stmt.setString(DB_FIELD.BARCODE.getInsertUpdateOffset(), trimAndComplain(barcode)); } else { stmt.setNull(DB_FIELD.BARCODE.getInsertUpdateOffset(), Types.VARCHAR); } stmt.setString(DB_FIELD.LOCATION.getInsertUpdateOffset(), trimAndComplain(location)); stmt.setString(DB_FIELD.PLATE_TYPE.getInsertUpdateOffset(), trimAndComplain(plateType)); if (solvent != null) { stmt.setString(DB_FIELD.SOLVENT.getInsertUpdateOffset(), trimAndComplain(solvent)); } else { stmt.setNull(DB_FIELD.SOLVENT.getInsertUpdateOffset(), Types.VARCHAR); } if (temperature == null) { stmt.setNull(DB_FIELD.TEMPERATURE.getInsertUpdateOffset(), Types.INTEGER); } else { stmt.setInt(DB_FIELD.TEMPERATURE.getInsertUpdateOffset(), temperature); } stmt.setString(DB_FIELD.CONTENT_TYPE.getInsertUpdateOffset(), contentType.name()); }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelIteratorTable.java
public void createGelIterator(CFGenKbAuthorization Authorization, CFGenKbGelIteratorBuff Buff) { final String S_ProcName = "createGelIterator"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww .j a v a2 s .com ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); long CartridgeId = Buff.getRequiredCartridgeId(); Integer CallerId = Buff.getOptionalCallerId(); Integer PrevId = Buff.getOptionalPrevId(); Integer NextId = Buff.getOptionalNextId(); String SourceText = Buff.getRequiredSourceText(); String IteratorName = Buff.getRequiredIteratorName(); String ExpandBefore = Buff.getOptionalExpandBefore(); String ExpandFirst = Buff.getOptionalExpandFirst(); String ExpandEach = Buff.getRequiredExpandEach(); String ExpandLast = Buff.getOptionalExpandLast(); String ExpandLone = Buff.getOptionalExpandLone(); String ExpandEmpty = Buff.getOptionalExpandEmpty(); String ExpandAfter = Buff.getOptionalExpandAfter(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_geliter( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); 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++, ClassCode); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setLong(argIdx++, CartridgeId); if (CallerId != null) { stmtCreateByPKey.setInt(argIdx++, CallerId.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (PrevId != null) { stmtCreateByPKey.setInt(argIdx++, PrevId.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (NextId != null) { stmtCreateByPKey.setInt(argIdx++, NextId.intValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtCreateByPKey.setString(argIdx++, SourceText); stmtCreateByPKey.setString(argIdx++, IteratorName); if (ExpandBefore != null) { stmtCreateByPKey.setString(argIdx++, ExpandBefore); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandFirst != null) { stmtCreateByPKey.setString(argIdx++, ExpandFirst); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setString(argIdx++, ExpandEach); if (ExpandLast != null) { stmtCreateByPKey.setString(argIdx++, ExpandLast); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandLone != null) { stmtCreateByPKey.setString(argIdx++, ExpandLone); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandEmpty != null) { stmtCreateByPKey.setString(argIdx++, ExpandEmpty); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandAfter != null) { stmtCreateByPKey.setString(argIdx++, ExpandAfter); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } try { resultSet = stmtCreateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFGenKbGelIteratorBuff createdBuff = unpackGelIteratorResultSetToBuff(resultSet); if ((resultSet != null) && 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.setRequiredCartridgeId(createdBuff.getRequiredCartridgeId()); Buff.setRequiredGelInstId(createdBuff.getRequiredGelInstId()); Buff.setOptionalCallerId(createdBuff.getOptionalCallerId()); Buff.setOptionalPrevId(createdBuff.getOptionalPrevId()); Buff.setOptionalNextId(createdBuff.getOptionalNextId()); Buff.setRequiredSourceText(createdBuff.getRequiredSourceText()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setRequiredIteratorName(createdBuff.getRequiredIteratorName()); Buff.setOptionalExpandBefore(createdBuff.getOptionalExpandBefore()); Buff.setOptionalExpandFirst(createdBuff.getOptionalExpandFirst()); Buff.setRequiredExpandEach(createdBuff.getRequiredExpandEach()); Buff.setOptionalExpandLast(createdBuff.getOptionalExpandLast()); Buff.setOptionalExpandLone(createdBuff.getOptionalExpandLone()); Buff.setOptionalExpandEmpty(createdBuff.getOptionalExpandEmpty()); Buff.setOptionalExpandAfter(createdBuff.getOptionalExpandAfter()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:com.wso2telco.dep.ratecardservice.dao.OperationRateDAO.java
public OperationRateDTO addOperationRate(OperationRateDTO operationRate) throws BusinessException { Connection con = null;/*from w w w . java2 s . co m*/ PreparedStatement ps = null; ResultSet rs = null; Integer operationRateId = 0; try { con = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_RATE_DB); if (con == null) { log.error("unable to open " + DataSourceNames.WSO2TELCO_RATE_DB + " database connection"); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } StringBuilder query = new StringBuilder("insert into "); query.append(DatabaseTables.OPERATION_RATE.getTObject()); query.append(" (operator_id, api_operationid, rate_defid, createdby)"); query.append(" values"); query.append(" (?, ?, ?, ?)"); ps = con.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS); log.debug("sql query in addOperationRate : " + ps); Integer operatorId = operationRate.getOperator().getOperatorId(); if (operatorId != null) { ps.setInt(1, operatorId); } else { ps.setNull(1, Types.INTEGER); } ps.setInt(2, operationRate.getApiOperation().getApiOperationId()); ps.setInt(3, operationRate.getRateDefinition().getRateDefId()); ps.setString(4, operationRate.getCreatedBy()); ps.executeUpdate(); rs = ps.getGeneratedKeys(); while (rs.next()) { operationRateId = rs.getInt(1); } operationRate.setOperationRateId(operationRateId); } catch (SQLException e) { log.error("database operation error in addOperationRate : ", e); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } catch (Exception e) { log.error("error in addOperationRate : ", e); throw new BusinessException(ServiceError.SERVICE_ERROR_OCCURED); } finally { DbUtils.closeAllConnections(ps, con, rs); } return operationRate; }
From source file:ca.sqlpower.architect.swingui.TestPlayPen.java
/** * Test to ensure that when importing two copies of a self-referencing table, the * correct number of relationships get added, and furthermore, the relationships * all point to the correct table./*from w ww. ja v a 2 s .co m*/ * @throws Exception */ public void testImportTableCopyOnTwoCopiesOfSelfReferencingTable() throws Exception { SQLDatabase sourceDB = new SQLDatabase(); pp.getSession().getRootObject().addChild(sourceDB); SQLTable table = new SQLTable(sourceDB, true); table.setName("self_ref"); SQLColumn pkCol = new SQLColumn(table, "key", Types.INTEGER, 10, 0); table.addColumn(pkCol); table.addToPK(table.getColumn(0)); SQLColumn fkCol = new SQLColumn(table, "self_ref_column", Types.INTEGER, 10, 0); table.addColumn(fkCol); SQLRelationship rel = new SQLRelationship(); rel.attachRelationship(table, table, false); rel.addMapping(pkCol, fkCol); sourceDB.addChild(table); pp.importTableCopy(table, new Point(10, 10), ASUtils.createDuplicateProperties(pp.getSession(), table)); pp.importTableCopy(table, new Point(30, 30), ASUtils.createDuplicateProperties(pp.getSession(), table)); int relCount = 0; int tabCount = 0; int otherCount = 0; for (PlayPenComponent ppc : pp.getContentPane().getChildren()) { if (ppc instanceof Relationship) { relCount++; } else if (ppc instanceof TablePane) { tabCount++; } else { otherCount++; } } assertEquals("Expected two tables in pp", 2, tabCount); assertEquals("Expected two relationships in pp", 2, relCount); assertEquals("Found junk in playpen", 0, otherCount); for (SQLTable t : pp.getTables()) { List<SQLRelationship> exportedKeys = t.getExportedKeys(); List<SQLRelationship> importedKeys = SQLRelationship.getExportedKeys(t.getImportedKeys()); assertEquals("Expected only one exported key in table", 1, exportedKeys.size()); assertEquals("Expected only one imported key in table", 1, importedKeys.size()); SQLRelationship exportedKey = exportedKeys.get(0); SQLRelationship importedKey = importedKeys.get(0); assertEquals("Expected exported key PK and FK tables to be the same", exportedKey.getFkTable(), exportedKey.getPkTable()); assertEquals("Expected imported key PK and FK tables to be the same", importedKey.getFkTable(), importedKey.getPkTable()); assertEquals("Expected exported key and imported key tables to be the same", exportedKey.getPkTable(), importedKey.getPkTable()); } }
From source file:org.jfree.data.jdbc.JDBCXYDataset.java
/** * ExecuteQuery will attempt execute the query passed to it against the * provided database connection. If connection is null then no action is * taken.// w ww.java 2 s . c o m * * The results from the query are extracted and cached locally, thus * applying an upper limit on how many rows can be retrieved successfully. * * @param query the query to be executed. * @param con the connection the query is to be executed against. * * @throws SQLException if there is a problem executing the query. */ public void executeQuery(Connection con, String query) throws SQLException { if (con == null) { throw new SQLException("There is no database to execute the query."); } ResultSet resultSet = null; Statement statement = null; try { statement = con.createStatement(); resultSet = statement.executeQuery(query); ResultSetMetaData metaData = resultSet.getMetaData(); int numberOfColumns = metaData.getColumnCount(); int numberOfValidColumns = 0; int[] columnTypes = new int[numberOfColumns]; for (int column = 0; column < numberOfColumns; column++) { try { int type = metaData.getColumnType(column + 1); switch (type) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIT: case Types.DATE: case Types.TIME: case Types.TIMESTAMP: case Types.BIGINT: case Types.SMALLINT: ++numberOfValidColumns; columnTypes[column] = type; break; default: columnTypes[column] = Types.NULL; break; } } catch (SQLException e) { columnTypes[column] = Types.NULL; throw e; } } if (numberOfValidColumns <= 1) { throw new SQLException("Not enough valid columns where generated by query."); } /// First column is X data this.columnNames = new String[numberOfValidColumns - 1]; /// Get the column names and cache them. int currentColumn = 0; for (int column = 1; column < numberOfColumns; column++) { if (columnTypes[column] != Types.NULL) { this.columnNames[currentColumn] = metaData.getColumnLabel(column + 1); ++currentColumn; } } // Might need to add, to free memory from any previous result sets if (this.rows != null) { for (int column = 0; column < this.rows.size(); column++) { ArrayList row = (ArrayList) this.rows.get(column); row.clear(); } this.rows.clear(); } // Are we working with a time series. switch (columnTypes[0]) { case Types.DATE: case Types.TIME: case Types.TIMESTAMP: this.isTimeSeries = true; break; default: this.isTimeSeries = false; break; } // Get all rows. // rows = new ArrayList(); while (resultSet.next()) { ArrayList newRow = new ArrayList(); for (int column = 0; column < numberOfColumns; column++) { Object xObject = resultSet.getObject(column + 1); switch (columnTypes[column]) { case Types.NUMERIC: case Types.REAL: case Types.INTEGER: case Types.DOUBLE: case Types.FLOAT: case Types.DECIMAL: case Types.BIGINT: case Types.SMALLINT: newRow.add(xObject); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: newRow.add(new Long(((Date) xObject).getTime())); break; case Types.NULL: break; default: System.err.println("Unknown data"); columnTypes[column] = Types.NULL; break; } } this.rows.add(newRow); } /// a kludge to make everything work when no rows returned if (this.rows.size() == 0) { ArrayList newRow = new ArrayList(); for (int column = 0; column < numberOfColumns; column++) { if (columnTypes[column] != Types.NULL) { newRow.add(new Integer(0)); } } this.rows.add(newRow); } /// Determine max and min values. if (this.rows.size() < 1) { this.maxValue = 0.0; this.minValue = 0.0; } else { ArrayList row = (ArrayList) this.rows.get(0); this.maxValue = Double.NEGATIVE_INFINITY; this.minValue = Double.POSITIVE_INFINITY; for (int rowNum = 0; rowNum < this.rows.size(); ++rowNum) { row = (ArrayList) this.rows.get(rowNum); for (int column = 1; column < numberOfColumns; column++) { Object testValue = row.get(column); if (testValue != null) { double test = ((Number) testValue).doubleValue(); if (test < this.minValue) { this.minValue = test; } if (test > this.maxValue) { this.maxValue = test; } } } } } fireDatasetChanged(new DatasetChangeInfo()); //TODO: fill in real change info } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { // TODO: is this a good idea? } } if (statement != null) { try { statement.close(); } catch (Exception e) { // TODO: is this a good idea? } } } }
From source file:com.squid.core.domain.operators.ExtendedType.java
/** * compute a type "order" that can be used to compare types and promote types. * The order is a couple (x,y), where x represent a family type (string,date,numbers) and y an order in that family * A type should be promoted to the higher order. * @return/*ww w . j a v a 2s . c o m*/ */ public int[] computeTypeOrder() { switch (getDataType()) { case Types.BIT: return new int[] { NUMBER_ORDER, 0 }; case Types.BOOLEAN: return new int[] { NUMBER_ORDER, 1 }; case Types.TINYINT: return new int[] { NUMBER_ORDER, 2 }; case Types.SMALLINT: return new int[] { NUMBER_ORDER, 3 }; case Types.INTEGER: return new int[] { NUMBER_ORDER, 4 }; case Types.BIGINT: return new int[] { NUMBER_ORDER, 5 }; /////////////////////////// case Types.REAL: return new int[] { NUMBER_ORDER, 6 }; case Types.DOUBLE: case Types.FLOAT: return new int[] { NUMBER_ORDER, 7 }; case Types.DECIMAL: return new int[] { NUMBER_ORDER, 8 }; case Types.NUMERIC: return new int[] { NUMBER_ORDER, 9 }; ////////////////////////// case Types.CHAR: return new int[] { STRING_ORDER, 0 }; case Types.VARCHAR: return new int[] { STRING_ORDER, 1 }; case Types.LONGVARCHAR: return new int[] { STRING_ORDER, 2 }; case Types.CLOB: return new int[] { STRING_ORDER, 3 }; /////////////////////////// case Types.TIME: return new int[] { DATE_ORDER, 1 }; case Types.DATE: return new int[] { DATE_ORDER, 2 }; case Types.TIMESTAMP: return new int[] { DATE_ORDER, 3 }; case CustomTypes.INTERVAL: return new int[] { DATE_ORDER, 4 }; /////////////////////////// default: return new int[] { UNKNOWN_ORDER, 0 }; } }
From source file:com.micromux.cassandra.jdbc.JdbcRegressionTest.java
/** * Create a column group and confirm that the {@code ResultSetMetaData} works. *//*from w ww . j a v a2 s .c om*/ @Test public void testResultSetMetaData() throws Exception { Statement stmt = con.createStatement(); // Create the target Column family String createCF = "CREATE COLUMNFAMILY t33 (k int PRIMARY KEY," + "c text " + ") ;"; stmt.execute(createCF); stmt.close(); con.close(); // open it up again to see the new CF con = DriverManager .getConnection(String.format("jdbc:cassandra://%s:%d/%s?%s", HOST, PORT, KEYSPACE, OPTIONS)); // paraphrase of the snippet from the ISSUE #33 provided test PreparedStatement statement = con.prepareStatement("update t33 set c=? where k=123"); statement.setString(1, "mark"); statement.executeUpdate(); ResultSet result = statement.executeQuery("SELECT k, c FROM t33;"); ResultSetMetaData metadata = result.getMetaData(); int colCount = metadata.getColumnCount(); System.out.println("Test Issue #33"); DatabaseMetaData md = con.getMetaData(); System.out.println(); System.out.println("--------------"); System.out.println("Driver Version : " + md.getDriverVersion()); System.out.println("DB Version : " + md.getDatabaseProductVersion()); System.out.println("Catalog term : " + md.getCatalogTerm()); System.out.println("Catalog : " + con.getCatalog()); System.out.println("Schema term : " + md.getSchemaTerm()); System.out.println("--------------"); while (result.next()) { metadata = result.getMetaData(); colCount = metadata.getColumnCount(); assertEquals("Total column count should match schema for t33", 2, metadata.getColumnCount()); System.out.printf("(%d) ", result.getRow()); for (int i = 1; i <= colCount; i++) { System.out.print(showColumn(i, result) + " "); switch (i) { case 1: assertEquals("First Column: k", "k", metadata.getColumnName(1)); assertEquals("First Column Type: int", Types.INTEGER, metadata.getColumnType(1)); break; case 2: assertEquals("Second Column: c", "c", metadata.getColumnName(2)); assertEquals("Second Column Type: text", Types.NVARCHAR, metadata.getColumnType(2)); break; } } System.out.println(); } }
From source file:cn.gov.scciq.timer.acceptOrder.FRMDao.java
/** * ?CIQ?/* w ww . j a v a 2s .co m*/ * @return */ public static int saveCIQGoodsInfo(CEMSGoodsDataDto goodsDto) { int retCode = -1; Connection conn = null; CallableStatement proc = null; String call = "{call Pro_SaveCIQGoodsInfo(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"; try { conn = DBPool.ds.getConnection(); proc = conn.prepareCall(call); proc.setString(1, goodsDto.getDecl_No()); proc.setString(2, goodsDto.getGoods_No()); proc.setString(3, goodsDto.getHS_Code()); proc.setString(4, goodsDto.getGoods_CName()); proc.setString(5, goodsDto.getGoods_EName()); proc.setString(6, goodsDto.getGoods_Model()); proc.setString(7, goodsDto.getOrigin_Place_Code()); proc.setString(8, goodsDto.getOrigin_Country_Code()); proc.setString(9, goodsDto.getWeight()); proc.setString(10, goodsDto.getWeight_Unit_Code()); proc.setString(11, goodsDto.getSTD_Weight()); proc.setString(12, goodsDto.getSTD_Weight_Unit_Code()); proc.setString(13, goodsDto.getQTY()); proc.setString(14, goodsDto.getQTY_Unit_Code()); proc.setString(15, goodsDto.getSTD_QTY()); proc.setString(16, goodsDto.getSTD_QTY_Unit_Code()); proc.setString(17, goodsDto.getPack_Number()); proc.setString(18, goodsDto.getPack_Type_Code()); proc.setString(19, goodsDto.getCCY()); proc.setString(20, goodsDto.getRate()); proc.setString(21, goodsDto.getPrice()); proc.setString(22, goodsDto.getGoods_Values()); proc.setString(23, goodsDto.getValues_USD()); proc.setString(24, goodsDto.getValues_RMB()); proc.setString(25, goodsDto.getCIQ_CODE()); proc.setString(26, goodsDto.getINSP_MODE_CODE()); proc.setString(27, goodsDto.getCONDITION_FLAG()); proc.setString(28, goodsDto.getWASTE_FLAG()); proc.setString(29, goodsDto.getCHECKUP_TYPE_CODE()); proc.setString(30, goodsDto.getCHECKUP_WORK_CODE()); proc.setString(31, goodsDto.getSITUATION_CODE()); proc.setString(32, goodsDto.getSITUATION_LEVEL()); proc.setString(33, goodsDto.getPURPOSE_CODE()); proc.setString(34, goodsDto.getNOTIFY_NOS()); proc.setString(35, goodsDto.getPROD_NO()); proc.setString(36, goodsDto.getCOMBBATCH_NO()); proc.registerOutParameter(37, Types.INTEGER); proc.execute(); retCode = proc.getInt(37); } catch (SQLException e) { // TODO Auto-generated catch block log.error("N30", e); } catch (Exception e) { log.error("N31", e); } finally { try { if (proc != null) { proc.close(); } if (conn != null) { conn.close(); } } catch (SQLException e) { // TODO Auto-generated catch block log.error("N32", e); } } return retCode; }
From source file:com.netspective.axiom.sql.StoredProcedureParameter.java
/** * Apply the IN/OUT parameters of the callable statement object * * @param vac the context in which the apply action is being performed * @param stmt the statement object/*from w w w .j a v a 2 s .c o m*/ */ public void apply(StoredProcedureParameters.ValueApplyContext vac, ConnectionContext cc, CallableStatement stmt) throws SQLException { int paramNum = vac.getNextParamNum(); int jdbcType = getSqlType().getJdbcType(); if (getType().getValueIndex() == Type.IN || getType().getValueIndex() == Type.IN_OUT) { String text = value.getTextValue(cc); switch (jdbcType) { case Types.VARCHAR: // user override value if it exists if (vac.hasOverrideValues() && vac.hasActiveParamOverrideValue()) text = (String) vac.getActiveParamOverrideValue(); if (allowNull && text == null) stmt.setNull(paramNum, Types.VARCHAR); else if (text != null) stmt.setObject(paramNum, text); else log.warn("Parameter '" + getName() + "' was not bound. Value = " + text); break; case Types.CHAR: if (vac.hasOverrideValues() && vac.hasActiveParamOverrideValue()) text = (String) vac.getActiveParamOverrideValue(); if (allowNull && text == null) stmt.setNull(paramNum, Types.CHAR); else if (text != null) stmt.setObject(paramNum, text.substring(0, 1)); else log.warn("Parameter '" + getName() + "' was not bound. Value = " + text); break; case Types.INTEGER: if (vac.hasOverrideValues() && vac.hasActiveParamOverrideValue()) text = vac.getActiveParamOverrideValue() != null ? vac.getActiveParamOverrideValue().toString() : null; if (allowNull && text == null) stmt.setNull(paramNum, Types.INTEGER); else if (text != null) stmt.setInt(paramNum, Integer.parseInt(text)); else log.warn("Parameter '" + getName() + "' was not bound. Value = " + text); break; case Types.DOUBLE: if (vac.hasOverrideValues() && vac.hasActiveParamOverrideValue()) text = vac.getActiveParamOverrideValue() != null ? vac.getActiveParamOverrideValue().toString() : null; if (allowNull && text == null) stmt.setNull(paramNum, Types.DOUBLE); else if (text != null) stmt.setDouble(paramNum, Double.parseDouble(text)); else log.warn("Parameter '" + getName() + "' was not bound. Value = " + text); break; case Types.ARRAY: // Arrays are quite tricky. Right now, this is supporting String arrays only. // TODO: Support integer and float arrays also String[] textValues = value.getTextValues(cc); if (vac.hasOverrideValues() && vac.hasActiveParamOverrideValue()) textValues = (String[]) vac.getActiveParamOverrideValue(); applyInArrayValue(cc, stmt, paramNum, textValues); break; default: log.warn("Unknown JDBC type for parameter '" + getName() + "' (index=" + paramNum + ") of stored procedure '" + parent.getProcedure() + "'."); break; } } if (getType().getValueIndex() == Type.OUT || getType().getValueIndex() == Type.IN_OUT) { String identifier = getSqlType().getIdentifier(); // result sets are returned differently for different vendors if (identifier.equals(QueryParameterType.RESULTSET_IDENTIFIER)) stmt.registerOutParameter(paramNum, getVendorSpecificResultSetType(cc)); else stmt.registerOutParameter(paramNum, jdbcType); } }