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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelReferenceTable.java
public void updateGelReference(CFGenKbAuthorization Authorization, CFGenKbGelReferenceBuff Buff) { final String S_ProcName = "updateGelReference"; ResultSet resultSet = null;// ww w . j a va 2 s . c o m try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); long CartridgeId = Buff.getRequiredCartridgeId(); int GelInstId = Buff.getRequiredGelInstId(); Integer CallerId = Buff.getOptionalCallerId(); Integer PrevId = Buff.getOptionalPrevId(); Integer NextId = Buff.getOptionalNextId(); String SourceText = Buff.getRequiredSourceText(); String ReferenceName = Buff.getRequiredReferenceName(); Integer RemainderInstId = Buff.getOptionalRemainderInstId(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_gelrefer( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, ClassCode); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, CartridgeId); stmtUpdateByPKey.setInt(argIdx++, GelInstId); if (CallerId != null) { stmtUpdateByPKey.setInt(argIdx++, CallerId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (PrevId != null) { stmtUpdateByPKey.setInt(argIdx++, PrevId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (NextId != null) { stmtUpdateByPKey.setInt(argIdx++, NextId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtUpdateByPKey.setString(argIdx++, SourceText); stmtUpdateByPKey.setString(argIdx++, ReferenceName); if (RemainderInstId != null) { stmtUpdateByPKey.setInt(argIdx++, RemainderInstId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtUpdateByPKey.setInt(argIdx++, Revision); try { resultSet = stmtUpdateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFGenKbGelReferenceBuff updatedBuff = unpackGelReferenceResultSetToBuff(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.setOptionalCallerId(updatedBuff.getOptionalCallerId()); Buff.setOptionalPrevId(updatedBuff.getOptionalPrevId()); Buff.setOptionalNextId(updatedBuff.getOptionalNextId()); Buff.setRequiredSourceText(updatedBuff.getRequiredSourceText()); Buff.setRequiredReferenceName(updatedBuff.getRequiredReferenceName()); Buff.setOptionalRemainderInstId(updatedBuff.getOptionalRemainderInstId()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbPgSql.CFGenKbPgSqlNmTokenFormatterTable.java
public CFGenKbNmTokenFormatterBuff[] readBuffByGelExecIdx(CFGenKbAuthorization Authorization, long TenantId, long CartridgeId, Integer GelExecutableId) { final String S_ProcName = "readBuffByGelExecIdx"; ResultSet resultSet = null;/*from w w w .j av a 2 s. c o m*/ try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_kbnmtokenfmt_by_gelexecidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByGelExecIdx == null) { stmtReadBuffByGelExecIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByGelExecIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByGelExecIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByGelExecIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByGelExecIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByGelExecIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByGelExecIdx.setLong(argIdx++, TenantId); stmtReadBuffByGelExecIdx.setLong(argIdx++, CartridgeId); if (GelExecutableId != null) { stmtReadBuffByGelExecIdx.setInt(argIdx++, GelExecutableId.intValue()); } else { stmtReadBuffByGelExecIdx.setNull(argIdx++, java.sql.Types.INTEGER); } resultSet = stmtReadBuffByGelExecIdx.executeQuery(); List<CFGenKbNmTokenFormatterBuff> buffList = new LinkedList<CFGenKbNmTokenFormatterBuff>(); while (resultSet.next()) { CFGenKbNmTokenFormatterBuff buff = unpackNmTokenFormatterResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFGenKbNmTokenFormatterBuff[] retBuff = new CFGenKbNmTokenFormatterBuff[buffList.size()]; Iterator<CFGenKbNmTokenFormatterBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } 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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPrefixLineTable.java
public void updateGelPrefixLine(CFGenKbAuthorization Authorization, CFGenKbGelPrefixLineBuff Buff) { final String S_ProcName = "updateGelPrefixLine"; ResultSet resultSet = null;/*w ww .j av a 2 s . c om*/ try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); long CartridgeId = Buff.getRequiredCartridgeId(); int GelInstId = Buff.getRequiredGelInstId(); Integer CallerId = Buff.getOptionalCallerId(); Integer PrevId = Buff.getOptionalPrevId(); Integer NextId = Buff.getOptionalNextId(); String SourceText = Buff.getRequiredSourceText(); String PrefixName = Buff.getRequiredPrefixName(); Integer RemainderInstId = Buff.getOptionalRemainderInstId(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_gelprefix( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, ClassCode); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setLong(argIdx++, CartridgeId); stmtUpdateByPKey.setInt(argIdx++, GelInstId); if (CallerId != null) { stmtUpdateByPKey.setInt(argIdx++, CallerId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (PrevId != null) { stmtUpdateByPKey.setInt(argIdx++, PrevId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } if (NextId != null) { stmtUpdateByPKey.setInt(argIdx++, NextId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtUpdateByPKey.setString(argIdx++, SourceText); stmtUpdateByPKey.setString(argIdx++, PrefixName); if (RemainderInstId != null) { stmtUpdateByPKey.setInt(argIdx++, RemainderInstId.intValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER); } stmtUpdateByPKey.setInt(argIdx++, Revision); try { resultSet = stmtUpdateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFGenKbGelPrefixLineBuff updatedBuff = unpackGelPrefixLineResultSetToBuff(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.setOptionalCallerId(updatedBuff.getOptionalCallerId()); Buff.setOptionalPrevId(updatedBuff.getOptionalPrevId()); Buff.setOptionalNextId(updatedBuff.getOptionalNextId()); Buff.setRequiredSourceText(updatedBuff.getRequiredSourceText()); Buff.setRequiredPrefixName(updatedBuff.getRequiredPrefixName()); Buff.setOptionalRemainderInstId(updatedBuff.getOptionalRemainderInstId()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } 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:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelIteratorTable.java
public CFGenKbGelIteratorBuff[] readBuffByNextIdx(CFGenKbAuthorization Authorization, long TenantId, long CartridgeId, Integer NextId) { final String S_ProcName = "readBuffByNextIdx"; ResultSet resultSet = null;//from w ww. ja va 2 s .c o m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_geliter_by_nextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByNextIdx == null) { stmtReadBuffByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByNextIdx.setLong(argIdx++, TenantId); stmtReadBuffByNextIdx.setLong(argIdx++, CartridgeId); if (NextId != null) { stmtReadBuffByNextIdx.setInt(argIdx++, NextId.intValue()); } else { stmtReadBuffByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } try { resultSet = stmtReadBuffByNextIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFGenKbGelIteratorBuff> buffList = new LinkedList<CFGenKbGelIteratorBuff>(); while ((resultSet != null) && resultSet.next()) { CFGenKbGelIteratorBuff buff = unpackGelIteratorResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFGenKbGelIteratorBuff[] retBuff = new CFGenKbGelIteratorBuff[buffList.size()]; Iterator<CFGenKbGelIteratorBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } 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:it.greenvulcano.gvesb.datahandling.dbo.DBOCallSP.java
/** * @see org.xml.sax.ContentHandler#endElement(java.lang.String, * java.lang.String, java.lang.String) *///w w w . ja va2 s . c o m @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (ROW_NAME.equals(localName)) { if (!currCriticalError) { executeStatement(); } else { rowDisc++; // aggiunta DiscardCause al dhr... String msg = currentXSLMessage; dhr.addDiscardCause(new DiscardCause(rowCounter, msg)); resultMessage.append("Data error on row ").append(rowCounter).append(": ").append(msg); resultMessage.append("SQL Statement Informations:\n").append(sqlStatementInfo); resultMessage.append("Record parameters:\n").append(dumpCurrentRowFields()); resultStatus = STATUS_PARTIAL; } } else if (COL_NAME.equals(localName)) { CallableStatement cs = (CallableStatement) sqlStatementInfo.getStatement(); try { if (!outOnly) { colDataExpecting = false; String text = textBuffer.toString(); if ((currentUUID != null) && (currentUUID.trim().length() > 0) && (text.length() == 0)) { text = uuids.get(currentUUID); if (text == null) { text = currentUUID; } } if (TIMESTAMP_TYPE.equals(currType) || DATE_TYPE.equals(currType) || TIME_TYPE.equals(currType)) { if (text.equals("")) { if (TIMESTAMP_TYPE.equals(currType)) setNull(cs, Types.TIMESTAMP); else if (DATE_TYPE.equals(currType)) setNull(cs, Types.DATE); else setNull(cs, Types.TIME); currentRowFields.add(null); } else { dateFormatter.applyPattern(currDateFormat); Date formattedDate = dateFormatter.parse(text); if (TIMESTAMP_TYPE.equals(currType)) { Timestamp ts = new Timestamp(formattedDate.getTime()); setTimestamp(cs, ts); currentRowFields.add(ts); } else if (DATE_TYPE.equals(currType)) { java.sql.Date d = new java.sql.Date(formattedDate.getTime()); setDate(cs, d); currentRowFields.add(d); } else { java.sql.Time t = new java.sql.Time(formattedDate.getTime()); setTime(cs, t); currentRowFields.add(t); } } } else if (INTEGER_TYPE.equals(currType) || SMALLINT_TYPE.equals(currType) || BIGINT_TYPE.equals(currType)) { if (text.equals("")) { if (INTEGER_TYPE.equals(currType)) setNull(cs, Types.INTEGER); else if (SMALLINT_TYPE.equals(currType)) setNull(cs, Types.SMALLINT); else setNull(cs, Types.BIGINT); currentRowFields.add(null); } else { if (INTEGER_TYPE.equals(currType)) setInt(cs, Integer.parseInt(text, 10)); else if (SMALLINT_TYPE.equals(currType)) setShort(cs, Short.parseShort(text, 10)); else setLong(cs, Long.parseLong(text, 10)); currentRowFields.add(text); } } else if (FLOAT_TYPE.equals(currType) || DOUBLE_TYPE.equals(currType) || DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType)) { if (text.equals("")) { if (DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType)) setNull(cs, Types.NUMERIC); else if (FLOAT_TYPE.equals(currType)) setNull(cs, Types.FLOAT); else setNull(cs, Types.DOUBLE); currentRowFields.add(null); } else { DecimalFormatSymbols dfs = numberFormatter.getDecimalFormatSymbols(); dfs.setDecimalSeparator(currDecSeparator.charAt(0)); dfs.setGroupingSeparator(currGroupSeparator.charAt(0)); numberFormatter.setDecimalFormatSymbols(dfs); numberFormatter.applyPattern(currNumberFormat); boolean isBigDecimal = numberFormatter.isParseBigDecimal(); try { numberFormatter.setParseBigDecimal(true); BigDecimal formattedNumber = (BigDecimal) numberFormatter.parse(text); if (DECIMAL_TYPE.equals(currType) || NUMERIC_TYPE.equals(currType)) { setBigDecimal(cs, formattedNumber); currentRowFields.add(formattedNumber); } else if (FLOAT_TYPE.equals(currType)) { setFloat(cs, formattedNumber.floatValue()); currentRowFields.add(formattedNumber.floatValue()); } else { setDouble(cs, formattedNumber.doubleValue()); currentRowFields.add(formattedNumber.doubleValue()); } } finally { numberFormatter.setParseBigDecimal(isBigDecimal); } } } else if (LONG_STRING_TYPE.equals(currType) || LONG_NSTRING_TYPE.equals(currType)) { if (text.equals("")) { if (LONG_STRING_TYPE.equals(currType)) setNull(cs, Types.CLOB); else setNull(cs, Types.NCLOB); currentRowFields.add(null); } else { if (LONG_STRING_TYPE.equals(currType)) { setCharacterStream(cs, new StringReader(text)); currentRowFields.add(text); } else { setNCharacterStream(cs, new StringReader(text)); currentRowFields.add(text); } } } else if (BASE64_TYPE.equals(currType)) { if (text.equals("")) { setNull(cs, Types.BLOB); currentRowFields.add(null); } else { byte[] data = text.getBytes(); data = Base64.getDecoder().decode(data); ByteArrayInputStream bais = new ByteArrayInputStream(data); setBinaryStream(cs, bais, data.length); currentRowFields.add(text); } } else if (BINARY_TYPE.equals(currType)) { if (text.equals("")) { setNull(cs, Types.BLOB); currentRowFields.add(null); } else { byte[] data = text.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(data); setBinaryStream(cs, bais, data.length); currentRowFields.add(text); } } else if (BOOLEAN_TYPE.equals(currType)) { if (text.equals("")) { setNull(cs, Types.BOOLEAN); currentRowFields.add(null); } else { setBoolean(cs, TextUtils.parseBoolean(text)); currentRowFields.add(text); } } else if (XML_TYPE.equals(currType)) { if (text.equals("")) { setNull(cs, Types.SQLXML); currentRowFields.add(null); } else { SQLXML xml = cs.getConnection().createSQLXML(); xml.setString(text); setSQLXML(cs, xml); currentRowFields.add(text); } } else if (NSTRING_TYPE.equals(currType)) { if (text.equals("")) { setNull(cs, Types.NVARCHAR); currentRowFields.add(null); } else { setNString(cs, text); currentRowFields.add(text); } } else { if (text.equals("")) { setNull(cs, Types.VARCHAR); currentRowFields.add(null); } else { setString(cs, text); currentRowFields.add(text); } } } else { currentRowFields.add(currentUUID); } } catch (ParseException exc) { throw new SAXException(exc); } catch (SQLException exc) { OracleExceptionHandler.handleSQLException(exc); throw new SAXException(exc); } } }
From source file:com.draagon.meta.manager.db.driver.GenericSQLDriver.java
/** * Sets a specific value on a prepared statement *//*from w w w .java 2 s.c o m*/ protected void setStatementValue(PreparedStatement s, MetaField f, int index, Object value) throws SQLException { int j = index; switch (f.getType()) { case MetaField.BOOLEAN: { if (value == null) { s.setNull(j, Types.BIT); } else if (value instanceof Boolean) { s.setBoolean(j, ((Boolean) value).booleanValue()); } else { s.setBoolean(j, Boolean.valueOf(value.toString()).booleanValue()); } } break; case MetaField.BYTE: { if (value == null) { s.setNull(j, Types.TINYINT); } else if (value instanceof Byte) { s.setByte(j, ((Byte) value).byteValue()); } else { s.setByte(j, Byte.valueOf(value.toString()).byteValue()); } } break; case MetaField.SHORT: { if (value == null) { s.setNull(j, Types.SMALLINT); } else if (value instanceof Short) { s.setShort(j, ((Short) value).shortValue()); } else { s.setShort(j, Short.valueOf(value.toString()).shortValue()); } } break; case MetaField.INT: { if (value == null) { s.setNull(j, Types.INTEGER); } else if (value instanceof Integer) { s.setInt(j, ((Integer) value).intValue()); } else { s.setInt(j, Integer.valueOf(value.toString()).intValue()); } } break; case MetaField.DATE: // NOTE DATE IS TREATED AS LONG! { if (value == null) { s.setNull(j, Types.TIMESTAMP); } else if (value instanceof java.util.Date) { s.setTimestamp(j, new Timestamp(((java.util.Date) value).getTime())); } else { s.setTimestamp(j, new Timestamp(Long.valueOf(value.toString()).longValue())); } } break; case MetaField.LONG: { if (value == null) { s.setNull(j, Types.BIGINT); } else if (value instanceof Long) { s.setLong(j, ((Long) value).longValue()); } else { s.setLong(j, Long.valueOf(value.toString()).longValue()); } } break; // WARNING: This should not be a valid key case MetaField.FLOAT: { if (value == null) { s.setNull(j, Types.FLOAT); } else if (value instanceof Float) { s.setFloat(j, ((Float) value).floatValue()); } else { s.setFloat(j, Float.valueOf(value.toString()).floatValue()); } } break; // WARNING: This should not be a valid key case MetaField.DOUBLE: { if (value == null) { s.setNull(j, Types.DOUBLE); } else if (value instanceof Double) { s.setDouble(j, ((Double) value).doubleValue()); } else { s.setDouble(j, Double.valueOf(value.toString()).doubleValue()); } } break; case MetaField.STRING: if (value == null) { s.setNull(j, Types.VARCHAR); } else { s.setString(j, value.toString()); } break; case MetaField.OBJECT: //if ( value == null ) // s.setNull( j, Types.BLOB ); //else s.setObject(j, value); break; } }
From source file:com.zimbra.cs.db.DbMailItem.java
public static void persistCounts(MailItem item, Metadata metadata) throws ServiceException { Mailbox mbox = item.getMailbox();/* w w w. j a v a 2s.c om*/ DbConnection conn = mbox.getOperationConnection(); PreparedStatement stmt = null; try { stmt = conn.prepareStatement("UPDATE " + getMailItemTableName(item) + " SET size = ?, unread = ?, metadata = ?, mod_metadata = ?, change_date = ?, mod_content = ?" + " WHERE " + IN_THIS_MAILBOX_AND + "id = ?"); int pos = 1; stmt.setLong(pos++, item.getSize()); stmt.setInt(pos++, item.getUnreadCount()); stmt.setString(pos++, checkMetadataLength(metadata.toString())); stmt.setInt(pos++, item.getModifiedSequence()); if (item.getChangeDate() > 0) { stmt.setInt(pos++, (int) (item.getChangeDate() / 1000)); } else { stmt.setNull(pos++, Types.INTEGER); } stmt.setInt(pos++, item.getSavedSequence()); pos = setMailboxId(stmt, mbox, pos); stmt.setInt(pos++, item.getId()); stmt.executeUpdate(); } catch (SQLException e) { throw ServiceException .FAILURE("writing metadata for mailbox " + item.getMailboxId() + ", item " + item.getId(), e); } finally { DbPool.closeStatement(stmt); } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelModifierTable.java
public CFGenKbGelModifierBuff[] readBuffByLastInstIdx(CFGenKbAuthorization Authorization, long TenantId, long CartridgeId, Integer LastInstId) { final String S_ProcName = "readBuffByLastInstIdx"; ResultSet resultSet = null;//from ww w . j a v a 2s . c om try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_gelmodifier_by_lastinstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByLastInstIdx == null) { stmtReadBuffByLastInstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByLastInstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByLastInstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByLastInstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByLastInstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByLastInstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByLastInstIdx.setLong(argIdx++, TenantId); stmtReadBuffByLastInstIdx.setLong(argIdx++, CartridgeId); if (LastInstId != null) { stmtReadBuffByLastInstIdx.setInt(argIdx++, LastInstId.intValue()); } else { stmtReadBuffByLastInstIdx.setNull(argIdx++, java.sql.Types.INTEGER); } try { resultSet = stmtReadBuffByLastInstIdx.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } List<CFGenKbGelModifierBuff> buffList = new LinkedList<CFGenKbGelModifierBuff>(); while ((resultSet != null) && resultSet.next()) { CFGenKbGelModifierBuff buff = unpackGelModifierResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFGenKbGelModifierBuff[] retBuff = new CFGenKbGelModifierBuff[buffList.size()]; Iterator<CFGenKbGelModifierBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } 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:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMySql.CFCrmMySqlAttachmentTable.java
public void deleteAttachmentByMimeTypeIdx(CFCrmAuthorization Authorization, Integer argMimeTypeId) { final String S_ProcName = "deleteAttachmentByMimeTypeIdx"; ResultSet resultSet = null;// www .j a v a 2 s . co m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_delete_attchmnt_by_mimetypeidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByMimeTypeIdx == null) { stmtDeleteByMimeTypeIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByMimeTypeIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByMimeTypeIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByMimeTypeIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argMimeTypeId != null) { stmtDeleteByMimeTypeIdx.setInt(argIdx++, argMimeTypeId.intValue()); } else { stmtDeleteByMimeTypeIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByMimeTypeIdx.executeUpdate(); } 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.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine.java
/** * Maps the database type to {@link DbColumnType}. If there's no mapping a {@link DbColumnType#UNMAPPED} is returned. * * @param type The SQL type from {@link java.sql.Types}. * @return The {@link DbColumnType}./*from w ww .j a va 2s . c om*/ */ protected DbColumnType toPdbType(final int type) { switch (type) { case Types.ARRAY: return DbColumnType.UNMAPPED; case Types.BIGINT: return DbColumnType.LONG; case Types.BINARY: return DbColumnType.BLOB; case Types.BIT: return DbColumnType.BOOLEAN; case Types.BLOB: return DbColumnType.BLOB; case Types.BOOLEAN: return DbColumnType.BOOLEAN; case Types.CHAR: return DbColumnType.STRING; case Types.CLOB: return DbColumnType.STRING; case Types.DATALINK: return DbColumnType.UNMAPPED; case Types.DATE: return DbColumnType.UNMAPPED; case Types.DECIMAL: return DbColumnType.DOUBLE; case Types.DISTINCT: return DbColumnType.UNMAPPED; case Types.DOUBLE: return DbColumnType.DOUBLE; case Types.FLOAT: return DbColumnType.DOUBLE; case Types.INTEGER: return DbColumnType.INT; case Types.JAVA_OBJECT: return DbColumnType.BLOB; case Types.LONGNVARCHAR: return DbColumnType.STRING; case Types.LONGVARBINARY: return DbColumnType.BLOB; case Types.LONGVARCHAR: return DbColumnType.STRING; case Types.NCHAR: return DbColumnType.STRING; case Types.NCLOB: return DbColumnType.STRING; case Types.NULL: return DbColumnType.UNMAPPED; case Types.NUMERIC: return DbColumnType.DOUBLE; case Types.NVARCHAR: return DbColumnType.STRING; case Types.OTHER: return DbColumnType.UNMAPPED; case Types.REAL: return DbColumnType.DOUBLE; case Types.REF: return DbColumnType.UNMAPPED; case Types.ROWID: return DbColumnType.STRING; case Types.SMALLINT: return DbColumnType.INT; case Types.SQLXML: return DbColumnType.STRING; case Types.STRUCT: return DbColumnType.UNMAPPED; case Types.TIME: return DbColumnType.UNMAPPED; case Types.TIMESTAMP: return DbColumnType.LONG; case Types.TINYINT: return DbColumnType.INT; case Types.VARBINARY: return DbColumnType.BLOB; case Types.VARCHAR: return DbColumnType.STRING; default: return DbColumnType.UNMAPPED; } }