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.CFGenKbOracle.CFGenKbOracleGelExpansionTable.java
public void deleteGelExpansionByNextIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argNextId) { final String S_ProcName = "deleteGelExpansionByNextIdx"; ResultSet resultSet = null;/*ww w. j av a 2 s. c om*/ try { Connection cnx = schema.getCnx(); String sql = "begin call " + schema.getLowerSchemaDbName() + ".dl_gelexpansionbynextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); end"; if (stmtDeleteByNextIdx == null) { stmtDeleteByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByNextIdx.setLong(argIdx++, argTenantId); stmtDeleteByNextIdx.setLong(argIdx++, argCartridgeId); if (argNextId != null) { stmtDeleteByNextIdx.setInt(argIdx++, argNextId.intValue()); } else { stmtDeleteByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } int rowsUpdated = stmtDeleteByNextIdx.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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPopTable.java
public void deleteGelPopByRemainderIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argRemainderInstId) { final String S_ProcName = "deleteGelPopByRemainderIdx"; ResultSet resultSet = null;/*from w ww . j a v a 2 s . com*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelpop_by_remainderidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByRemainderIdx == null) { stmtDeleteByRemainderIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByRemainderIdx.setLong(argIdx++, argTenantId); stmtDeleteByRemainderIdx.setLong(argIdx++, argCartridgeId); if (argRemainderInstId != null) { stmtDeleteByRemainderIdx.setInt(argIdx++, argRemainderInstId.intValue()); } else { stmtDeleteByRemainderIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByRemainderIdx.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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelReferenceTable.java
public void deleteGelReferenceByRemainderIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argRemainderInstId) { final String S_ProcName = "deleteGelReferenceByRemainderIdx"; ResultSet resultSet = null;//from w ww . j a v a2s . com try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelrefer_by_remainderidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByRemainderIdx == null) { stmtDeleteByRemainderIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByRemainderIdx.setLong(argIdx++, argTenantId); stmtDeleteByRemainderIdx.setLong(argIdx++, argCartridgeId); if (argRemainderInstId != null) { stmtDeleteByRemainderIdx.setInt(argIdx++, argRemainderInstId.intValue()); } else { stmtDeleteByRemainderIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByRemainderIdx.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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelPrefixLineTable.java
public void deleteGelPrefixLineByRemainderIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argRemainderInstId) { final String S_ProcName = "deleteGelPrefixLineByRemainderIdx"; ResultSet resultSet = null;/*from www .j a v a2 s . c o m*/ try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelprefix_by_remainderidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByRemainderIdx == null) { stmtDeleteByRemainderIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByRemainderIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByRemainderIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByRemainderIdx.setLong(argIdx++, argTenantId); stmtDeleteByRemainderIdx.setLong(argIdx++, argCartridgeId); if (argRemainderInstId != null) { stmtDeleteByRemainderIdx.setInt(argIdx++, argRemainderInstId.intValue()); } else { stmtDeleteByRemainderIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByRemainderIdx.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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelIteratorTable.java
public void updateGelIterator(CFGenKbAuthorization Authorization, CFGenKbGelIteratorBuff Buff) { final String S_ProcName = "updateGelIterator"; ResultSet resultSet = null;//from www . j av a 2s.co 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 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(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_geliter( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, IteratorName); if (ExpandBefore != null) { stmtUpdateByPKey.setString(argIdx++, ExpandBefore); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandFirst != null) { stmtUpdateByPKey.setString(argIdx++, ExpandFirst); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setString(argIdx++, ExpandEach); if (ExpandLast != null) { stmtUpdateByPKey.setString(argIdx++, ExpandLast); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandLone != null) { stmtUpdateByPKey.setString(argIdx++, ExpandLone); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandEmpty != null) { stmtUpdateByPKey.setString(argIdx++, ExpandEmpty); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (ExpandAfter != null) { stmtUpdateByPKey.setString(argIdx++, ExpandAfter); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtUpdateByPKey.setInt(argIdx++, Revision); try { resultSet = stmtUpdateByPKey.executeQuery(); } catch (SQLException e) { if (e.getErrorCode() != 1329) { throw e; } resultSet = null; } if ((resultSet != null) && resultSet.next()) { CFGenKbGelIteratorBuff updatedBuff = 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.setOptionalCallerId(updatedBuff.getOptionalCallerId()); Buff.setOptionalPrevId(updatedBuff.getOptionalPrevId()); Buff.setOptionalNextId(updatedBuff.getOptionalNextId()); Buff.setRequiredSourceText(updatedBuff.getRequiredSourceText()); Buff.setRequiredIteratorName(updatedBuff.getRequiredIteratorName()); Buff.setOptionalExpandBefore(updatedBuff.getOptionalExpandBefore()); Buff.setOptionalExpandFirst(updatedBuff.getOptionalExpandFirst()); Buff.setRequiredExpandEach(updatedBuff.getRequiredExpandEach()); Buff.setOptionalExpandLast(updatedBuff.getOptionalExpandLast()); Buff.setOptionalExpandLone(updatedBuff.getOptionalExpandLone()); Buff.setOptionalExpandEmpty(updatedBuff.getOptionalExpandEmpty()); Buff.setOptionalExpandAfter(updatedBuff.getOptionalExpandAfter()); 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.CFGenKbMySqlGelModifierTable.java
public void deleteGelModifierByCallerIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argCallerId) { final String S_ProcName = "deleteGelModifierByCallerIdx"; ResultSet resultSet = null;// w w w.jav a 2 s. co m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelmodifier_by_calleridx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByCallerIdx == null) { stmtDeleteByCallerIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCallerIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCallerIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCallerIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCallerIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCallerIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByCallerIdx.setLong(argIdx++, argTenantId); stmtDeleteByCallerIdx.setLong(argIdx++, argCartridgeId); if (argCallerId != null) { stmtDeleteByCallerIdx.setInt(argIdx++, argCallerId.intValue()); } else { stmtDeleteByCallerIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByCallerIdx.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:edu.jhuapl.openessence.datasource.jdbc.entry.JdbcOeDataEntrySource.java
/** * Sets arguments of the proper type on a PreparedSatement * * @param pStmt prepared statement on which to set arguments * @param dimIds dimension ids that map to columns on the prepared statement * @param valueList values to set for the paramenters on the prepared statement * @param valueMap dimIds mapped to values to set for the paramenters on the prepared statement * @throws SQLException if error occurs while processing the prepared statement * @throws OeDataSourceException if error occurs converting value to it's sql type *//*from w w w .j av a 2 s .c o m*/ protected void setArgumentsOnSqlType(PreparedStatement pStmt, List<String> dimIds, List<Object> valueList, Map<String, Object> valueMap) throws SQLException, OeDataSourceException { if ((valueList == null && valueMap == null) || (valueList != null && valueMap != null)) { throw new OeDataSourceException("Invalid value lists. Only one form of the list can be provided."); } int argCount = 0; Object val; boolean isValueList = (valueList != null); for (String dimId : dimIds) { Dimension dim = getEditDimension(dimId); FieldType sqlType = dim.getSqlType(); if (isValueList) { val = valueList.get(argCount); } else { val = valueMap.get(dimId); } try { argCount++; switch (sqlType) { case DATE_TIME: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlTimestampType(val), Types.TIMESTAMP); continue; case DATE: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.DATE); continue; case BOOLEAN: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.BOOLEAN); continue; case FLOAT: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.FLOAT); continue; case DOUBLE: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.DOUBLE); continue; case INTEGER: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.INTEGER); continue; case LONG: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.BIGINT); continue; case TEXT: pStmt.setObject(argCount, DataTypeConversionHelper.convert2SqlType(val), Types.VARCHAR); continue; default: throw new AssertionError("Unexpected sqlType " + sqlType + "."); } } catch (OeDataSourceException e) { throw new SQLException("Error occured converting value \"" + val + "\" to its sql type.", e); } } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelModifierTable.java
public void deleteGelModifierByPrevIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argPrevId) { final String S_ProcName = "deleteGelModifierByPrevIdx"; ResultSet resultSet = null;//from www.j a v a 2 s .c om try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelmodifier_by_previdx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByPrevIdx == null) { stmtDeleteByPrevIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPrevIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPrevIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPrevIdx.setLong(argIdx++, argTenantId); stmtDeleteByPrevIdx.setLong(argIdx++, argCartridgeId); if (argPrevId != null) { stmtDeleteByPrevIdx.setInt(argIdx++, argPrevId.intValue()); } else { stmtDeleteByPrevIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByPrevIdx.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.cfcore.v2_0.CFGenKbMySql.CFGenKbMySqlGelModifierTable.java
public void deleteGelModifierByNextIdx(CFGenKbAuthorization Authorization, long argTenantId, long argCartridgeId, Integer argNextId) { final String S_ProcName = "deleteGelModifierByNextIdx"; ResultSet resultSet = null;//from w ww .j a va 2 s .c o m try { Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_gelmodifier_by_nextidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtDeleteByNextIdx == null) { stmtDeleteByNextIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByNextIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByNextIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByNextIdx.setLong(argIdx++, argTenantId); stmtDeleteByNextIdx.setLong(argIdx++, argCartridgeId); if (argNextId != null) { stmtDeleteByNextIdx.setInt(argIdx++, argNextId.intValue()); } else { stmtDeleteByNextIdx.setNull(argIdx++, java.sql.Types.INTEGER); } stmtDeleteByNextIdx.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:axiom.objectmodel.db.NodeManager.java
/** * Create a new Node from a ResultSet./* w w w. j a v a2s. c om*/ */ public Node createNode(DbMapping dbm, ResultSet rs, DbColumn[] columns, int offset) throws SQLException, IOException, ClassNotFoundException { HashMap propBuffer = new HashMap(); String id = null; String name = null; String protoName = dbm.getTypeName(); DbMapping dbmap = dbm; Node node = new Node(); for (int i = 0; i < columns.length; i++) { // set prototype? if (columns[i].isPrototypeField()) { protoName = rs.getString(i + 1 + offset); if (protoName != null) { dbmap = getDbMapping(protoName); if (dbmap == null) { // invalid prototype name! app.logError(ErrorReporter.errorMsg(this.getClass(), "createNode") + "Invalid prototype name: " + protoName + " - using default"); dbmap = dbm; protoName = dbmap.getTypeName(); } } } // set id? if (columns[i].isIdField()) { id = rs.getString(i + 1 + offset); // if id == null, the object doesn't actually exist - return null if (id == null) { return null; } } // set name? if (columns[i].isNameField()) { name = rs.getString(i + 1 + offset); } Property newprop = new Property(node); switch (columns[i].getType()) { case Types.BIT: newprop.setBooleanValue(rs.getBoolean(i + 1 + offset)); break; case Types.TINYINT: case Types.BIGINT: case Types.SMALLINT: case Types.INTEGER: newprop.setIntegerValue(rs.getLong(i + 1 + offset)); break; case Types.REAL: case Types.FLOAT: case Types.DOUBLE: newprop.setFloatValue(rs.getDouble(i + 1 + offset)); break; case Types.DECIMAL: case Types.NUMERIC: BigDecimal num = rs.getBigDecimal(i + 1 + offset); if (num == null) { break; } if (num.scale() > 0) { newprop.setFloatValue(num.doubleValue()); } else { newprop.setIntegerValue(num.longValue()); } break; case Types.VARBINARY: case Types.BINARY: // newprop.setStringValue(rs.getString(i+1+offset)); newprop.setJavaObjectValue(rs.getBytes(i + 1 + offset)); break; case Types.LONGVARBINARY: { InputStream in = rs.getBinaryStream(i + 1 + offset); if (in == null) { break; } ByteArrayOutputStream bout = new ByteArrayOutputStream(); byte[] buffer = new byte[2048]; int read; while ((read = in.read(buffer)) > -1) { bout.write(buffer, 0, read); } newprop.setJavaObjectValue(bout.toByteArray()); } break; case Types.LONGVARCHAR: try { newprop.setStringValue(rs.getString(i + 1 + offset)); } catch (SQLException x) { Reader in = rs.getCharacterStream(i + 1 + offset); char[] buffer = new char[2048]; int read = 0; int r; while ((r = in.read(buffer, read, buffer.length - read)) > -1) { read += r; if (read == buffer.length) { // grow input buffer char[] newBuffer = new char[buffer.length * 2]; System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); buffer = newBuffer; } } newprop.setStringValue(new String(buffer, 0, read)); } break; case Types.CHAR: case Types.VARCHAR: case Types.OTHER: newprop.setStringValue(rs.getString(i + 1 + offset)); break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: newprop.setDateValue(rs.getTimestamp(i + 1 + offset)); break; case Types.NULL: newprop.setStringValue(null); break; case Types.CLOB: Clob cl = rs.getClob(i + 1 + offset); if (cl == null) { newprop.setStringValue(null); break; } char[] c = new char[(int) cl.length()]; Reader isr = cl.getCharacterStream(); isr.read(c); newprop.setStringValue(String.copyValueOf(c)); break; default: newprop.setStringValue(rs.getString(i + 1 + offset)); break; } if (rs.wasNull()) { newprop.setStringValue(null); } propBuffer.put(columns[i].getName(), newprop); // mark property as clean, since it's fresh from the db newprop.dirty = false; } if (id == null) { return null; } Hashtable propMap = new Hashtable(); DbColumn[] columns2 = dbmap.getColumns(); for (int i = 0; i < columns2.length; i++) { Relation rel = columns2[i].getRelation(); if (rel != null && (rel.reftype == Relation.PRIMITIVE || rel.reftype == Relation.REFERENCE)) { Property prop = (Property) propBuffer.get(columns2[i].getName()); if (prop == null) { continue; } prop.setName(rel.propName); // if the property is a pointer to another node, change the property type to NODE if ((rel.reftype == Relation.REFERENCE) && rel.usesPrimaryKey()) { // FIXME: References to anything other than the primary key are not supported prop.convertToNodeReference(rel.otherType, this.app.getCurrentRequestEvaluator().getLayer()); } propMap.put(rel.propName.toLowerCase(), prop); } } node.init(dbmap, id, name, protoName, propMap, safe); return node; }