List of usage examples for java.sql Types SMALLINT
int SMALLINT
To view the source code for java.sql Types SMALLINT.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type SMALLINT
.
From source file:axiom.objectmodel.db.NodeManager.java
private void setStatementValues(PreparedStatement stmt, int stmtNumber, Property p, int columnType) throws SQLException { if (p.getValue() == null) { stmt.setNull(stmtNumber, columnType); } else {/*from www . j a v a2 s . c om*/ switch (columnType) { case Types.BIT: case Types.TINYINT: case Types.BIGINT: case Types.SMALLINT: case Types.INTEGER: stmt.setLong(stmtNumber, p.getIntegerValue()); break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: case Types.NUMERIC: case Types.DECIMAL: stmt.setDouble(stmtNumber, p.getFloatValue()); break; case Types.VARBINARY: case Types.BINARY: case Types.BLOB: stmt.setString(stmtNumber, p.getStringValue()); break; case Types.LONGVARBINARY: case Types.LONGVARCHAR: try { stmt.setString(stmtNumber, p.getStringValue()); } catch (SQLException x) { String str = p.getStringValue(); Reader r = new StringReader(str); stmt.setCharacterStream(stmtNumber, r, str.length()); } break; case Types.CLOB: String val = p.getStringValue(); Reader isr = new StringReader(val); stmt.setCharacterStream(stmtNumber, isr, val.length()); break; case Types.CHAR: case Types.VARCHAR: case Types.OTHER: stmt.setString(stmtNumber, p.getStringValue()); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: stmt.setTimestamp(stmtNumber, p.getTimestampValue()); break; case Types.NULL: stmt.setNull(stmtNumber, 0); break; default: stmt.setString(stmtNumber, p.getStringValue()); break; } } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlAccountEntryTable.java
public void deleteAccountEntryByDrCcyIdx(CFAccAuthorization Authorization, Short argDebitCurrencyId) { final String S_ProcName = "deleteAccountEntryByDrCcyIdx"; ResultSet resultSet = null;/*from w w w . j ava 2 s. c o m*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByDrCcyIdx == null) { stmtDeleteByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDebitCurrencyId != null) { stmtDeleteByDrCcyIdx.setShort(argIdx++, argDebitCurrencyId.shortValue()); } else { stmtDeleteByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtDeleteByDrCcyIdx.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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java
public void deleteAccountEntryByDrCcyIdx(CFAccAuthorization Authorization, Short argDebitCurrencyId) { final String S_ProcName = "deleteAccountEntryByDrCcyIdx"; ResultSet resultSet = null;//w w w .j a v a2 s . c om try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByDrCcyIdx == null) { stmtDeleteByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDebitCurrencyId != null) { stmtDeleteByDrCcyIdx.setShort(argIdx++, argDebitCurrencyId.shortValue()); } else { stmtDeleteByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtDeleteByDrCcyIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } 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.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAccountEntryTable.java
public void deleteAccountEntryByDrCcyIdx(CFAccAuthorization Authorization, Short argDebitCurrencyId) { final String S_ProcName = "deleteAccountEntryByDrCcyIdx"; ResultSet resultSet = null;//from ww w . j ava2 s.com try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_ac_entry_by_drccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByDrCcyIdx == null) { stmtDeleteByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDebitCurrencyId != null) { stmtDeleteByDrCcyIdx.setShort(argIdx++, argDebitCurrencyId.shortValue()); } else { stmtDeleteByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtDeleteByDrCcyIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } 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.cfacc.v2_0.CFAccMySql.CFAccMySqlAccountEntryTable.java
public void deleteAccountEntryByCrCcyIdx(CFAccAuthorization Authorization, Short argCreditCurrencyId) { final String S_ProcName = "deleteAccountEntryByCrCcyIdx"; ResultSet resultSet = null;//from w w w. j a va 2 s . c o m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByCrCcyIdx == null) { stmtDeleteByCrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argCreditCurrencyId != null) { stmtDeleteByCrCcyIdx.setShort(argIdx++, argCreditCurrencyId.shortValue()); } else { stmtDeleteByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } stmtDeleteByCrCcyIdx.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:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAccountEntryTable.java
public void deleteAccountEntryByDrCcyIdx(CFAccAuthorization Authorization, Short argDebitCurrencyId) { final String S_ProcName = "deleteAccountEntryByDrCcyIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*w w w . java2s.co m*/ ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "exec sp_delete_ac_entry_by_drccyidx ?, ?, ?, ?, ?" + ", " + "?"; if (stmtDeleteByDrCcyIdx == null) { stmtDeleteByDrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argDebitCurrencyId != null) { stmtDeleteByDrCcyIdx.setShort(argIdx++, argDebitCurrencyId.shortValue()); } else { stmtDeleteByDrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } Object stuff = null; boolean moreResults = stmtDeleteByDrCcyIdx.execute(); while (stuff == null) { try { moreResults = stmtDeleteByDrCcyIdx.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { stuff = stmtDeleteByDrCcyIdx.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtDeleteByDrCcyIdx.getUpdateCount()) { break; } } } 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:org.apache.ddlutils.platform.PlatformImplBase.java
/** * This is the core method to retrieve a value for a column from a result set. Its primary * purpose is to call the appropriate method on the result set, and to provide an extension * point where database-specific implementations can change this behavior. * /*from w w w . jav a 2 s .c o m*/ * @param resultSet The result set to extract the value from * @param columnName The name of the column; can be <code>null</code> in which case the * <code>columnIdx</code> will be used instead * @param columnIdx The index of the column's value in the result set; is only used if * <code>columnName</code> is <code>null</code> * @param jdbcType The jdbc type to extract * @return The value * @throws SQLException If an error occurred while accessing the result set */ protected Object extractColumnValue(ResultSet resultSet, String columnName, int columnIdx, int jdbcType) throws SQLException { boolean useIdx = (columnName == null); Object value; switch (jdbcType) { case Types.CHAR: case Types.VARCHAR: case Types.LONGVARCHAR: value = useIdx ? resultSet.getString(columnIdx) : resultSet.getString(columnName); break; case Types.NUMERIC: case Types.DECIMAL: value = useIdx ? resultSet.getBigDecimal(columnIdx) : resultSet.getBigDecimal(columnName); break; case Types.BIT: case Types.BOOLEAN: value = new Boolean(useIdx ? resultSet.getBoolean(columnIdx) : resultSet.getBoolean(columnName)); break; case Types.TINYINT: case Types.SMALLINT: case Types.INTEGER: value = new Integer(useIdx ? resultSet.getInt(columnIdx) : resultSet.getInt(columnName)); break; case Types.BIGINT: value = new Long(useIdx ? resultSet.getLong(columnIdx) : resultSet.getLong(columnName)); break; case Types.REAL: value = new Float(useIdx ? resultSet.getFloat(columnIdx) : resultSet.getFloat(columnName)); break; case Types.FLOAT: case Types.DOUBLE: value = new Double(useIdx ? resultSet.getDouble(columnIdx) : resultSet.getDouble(columnName)); break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: value = useIdx ? resultSet.getBytes(columnIdx) : resultSet.getBytes(columnName); break; case Types.DATE: value = useIdx ? resultSet.getDate(columnIdx) : resultSet.getDate(columnName); break; case Types.TIME: value = useIdx ? resultSet.getTime(columnIdx) : resultSet.getTime(columnName); break; case Types.TIMESTAMP: value = useIdx ? resultSet.getTimestamp(columnIdx) : resultSet.getTimestamp(columnName); break; case Types.CLOB: Clob clob = useIdx ? resultSet.getClob(columnIdx) : resultSet.getClob(columnName); if (clob == null) { value = null; } else { long length = clob.length(); if (length > Integer.MAX_VALUE) { value = clob; } else if (length == 0) { // the javadoc is not clear about whether Clob.getSubString // can be used with a substring length of 0 // thus we do the safe thing and handle it ourselves value = ""; } else { value = clob.getSubString(1l, (int) length); } } break; case Types.BLOB: Blob blob = useIdx ? resultSet.getBlob(columnIdx) : resultSet.getBlob(columnName); if (blob == null) { value = null; } else { long length = blob.length(); if (length > Integer.MAX_VALUE) { value = blob; } else if (length == 0) { // the javadoc is not clear about whether Blob.getBytes // can be used with for 0 bytes to be copied // thus we do the safe thing and handle it ourselves value = new byte[0]; } else { value = blob.getBytes(1l, (int) length); } } break; case Types.ARRAY: value = useIdx ? resultSet.getArray(columnIdx) : resultSet.getArray(columnName); break; case Types.REF: value = useIdx ? resultSet.getRef(columnIdx) : resultSet.getRef(columnName); break; default: value = useIdx ? resultSet.getObject(columnIdx) : resultSet.getObject(columnName); break; } return resultSet.wasNull() ? null : value; }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWAccountEntryTable.java
public void deleteAccountEntryByCrCcyIdx(CFAccAuthorization Authorization, Short argCreditCurrencyId) { final String S_ProcName = "deleteAccountEntryByCrCcyIdx"; ResultSet resultSet = null;/*from w w w . ja v a 2s . c o m*/ try { Connection cnx = schema.getCnx(); final String sql = "CALL sp_delete_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtDeleteByCrCcyIdx == null) { stmtDeleteByCrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argCreditCurrencyId != null) { stmtDeleteByCrCcyIdx.setShort(argIdx++, argCreditCurrencyId.shortValue()); } else { stmtDeleteByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtDeleteByCrCcyIdx.executeQuery(); if (resultSet.next()) { int deleteFlag = resultSet.getInt(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } 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.cfacc.v2_0.CFAccPgSql.CFAccPgSqlAccountEntryTable.java
public void deleteAccountEntryByCrCcyIdx(CFAccAuthorization Authorization, Short argCreditCurrencyId) { final String S_ProcName = "deleteAccountEntryByCrCcyIdx"; ResultSet resultSet = null;/* w ww . j a v a2 s . c o m*/ try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_ac_entry_by_crccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByCrCcyIdx == null) { stmtDeleteByCrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argCreditCurrencyId != null) { stmtDeleteByCrCcyIdx.setShort(argIdx++, argCreditCurrencyId.shortValue()); } else { stmtDeleteByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } resultSet = stmtDeleteByCrCcyIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } 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.cfacc.v2_0.CFAccMSSql.CFAccMSSqlAccountEntryTable.java
public void deleteAccountEntryByCrCcyIdx(CFAccAuthorization Authorization, Short argCreditCurrencyId) { final String S_ProcName = "deleteAccountEntryByCrCcyIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w ww.j av a2 s.c o m*/ ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "exec sp_delete_ac_entry_by_crccyidx ?, ?, ?, ?, ?" + ", " + "?"; if (stmtDeleteByCrCcyIdx == null) { stmtDeleteByCrCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCrCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCrCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argCreditCurrencyId != null) { stmtDeleteByCrCcyIdx.setShort(argIdx++, argCreditCurrencyId.shortValue()); } else { stmtDeleteByCrCcyIdx.setNull(argIdx++, java.sql.Types.SMALLINT); } Object stuff = null; boolean moreResults = stmtDeleteByCrCcyIdx.execute(); while (stuff == null) { try { moreResults = stmtDeleteByCrCcyIdx.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { stuff = stmtDeleteByCrCcyIdx.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtDeleteByCrCcyIdx.getUpdateCount()) { break; } } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }