List of usage examples for java.sql Types VARCHAR
int VARCHAR
To view the source code for java.sql Types VARCHAR.
Click Source Link
The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type VARCHAR
.
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMSSql.CFAsteriskMSSqlDomainBaseTable.java
public void createDomainBase(CFSecurityAuthorization Authorization, CFInternetDomainBaseBuff Buff) { final String S_ProcName = "createDomainBase"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w w w . j a v a2 s . com*/ ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); String sql = "exec sp_create_bdomdef ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, ClassCode); stmtCreateByPKey.setLong(argIdx++, TenantId); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.execute(); boolean moreResults = true; resultSet = null; while (resultSet == null) { try { moreResults = stmtCreateByPKey.getMoreResults(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (moreResults) { try { resultSet = stmtCreateByPKey.getResultSet(); } catch (SQLException e) { } } else if (-1 == stmtCreateByPKey.getUpdateCount()) { break; } } if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "resultSet"); } if (resultSet.next()) { CFInternetDomainBaseBuff createdBuff = unpackDomainBaseResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMySql.CFAsteriskMySqlProjectBaseTable.java
public void createProjectBase(CFSecurityAuthorization Authorization, CFInternetProjectBaseBuff Buff) { final String S_ProcName = "createProjectBase"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* www . j a v a 2s. c o m*/ ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_bprjdef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; 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); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } 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()) { CFInternetProjectBaseBuff createdBuff = unpackProjectBaseResultSetToBuff(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.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:com.sangupta.fileanalysis.db.DBResultViewer.java
private int getColumnSize(final String tableName, final String columnName, final int columnType) { // check if we have the value in database cache int size = database.getColSize(tableName, columnName); if (size > 0) { return size; }/*from w w w . j a va 2 s . co m*/ switch (columnType) { case Types.VARCHAR: return 255; case Types.INTEGER: return 10; case Types.BOOLEAN: return 3; case Types.DOUBLE: return 14; case Types.BIGINT: return 20; case Types.TIMESTAMP: return 26; } return 10; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlProjectBaseTable.java
public void createProjectBase(CFSecurityAuthorization Authorization, CFInternetProjectBaseBuff Buff) { final String S_ProcName = "createProjectBase"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w.ja v a2s.c om ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_bprjdef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, ClassCode); stmtCreateByPKey.setLong(argIdx++, TenantId); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFInternetProjectBaseBuff createdBuff = unpackProjectBaseResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlSecDeviceTable.java
public void createSecDevice(CFEnSyntaxAuthorization Authorization, CFEnSyntaxSecDeviceBuff Buff) { final String S_ProcName = "createSecDevice"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w ww. j a va 2 s . c o m*/ ResultSet resultSet = null; try { UUID SecUserId = Buff.getRequiredSecUserId(); String DevName = Buff.getRequiredDevName(); String PubKey = Buff.getOptionalPubKey(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_secdev( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; 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++, "SDEV"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, DevName); if (PubKey != null) { stmtCreateByPKey.setString(argIdx++, PubKey); } 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()) { CFEnSyntaxSecDeviceBuff createdBuff = unpackSecDeviceResultSetToBuff(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.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredDevName(createdBuff.getRequiredDevName()); Buff.setOptionalPubKey(createdBuff.getOptionalPubKey()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:architecture.ee.web.logo.dao.jdbc.JdbcLogoImageDao.java
public void updateLogoImage(LogoImage logoImage, InputStream is) { if (logoImage.isPrimary()) { getExtendedJdbcTemplate().update( getBoundSql("ARCHITECTURE_WEB.RESET_LOGO_IMAGE_BY_OBJECT_TYPE_AND_OBJECT_ID").getSql(), new SqlParameterValue(Types.INTEGER, logoImage.getObjectType()), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectId())); }/*www . j av a2 s .co m*/ getExtendedJdbcTemplate().update(getBoundSql("ARCHITECTURE_WEB.UPDATE_LOGO_IMAGE").getSql(), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectType()), new SqlParameterValue(Types.NUMERIC, logoImage.getObjectId()), new SqlParameterValue(Types.NUMERIC, logoImage.isPrimary() ? 1 : 0), new SqlParameterValue(Types.VARCHAR, logoImage.getFilename()), new SqlParameterValue(Types.NUMERIC, logoImage.getImageSize()), new SqlParameterValue(Types.VARCHAR, logoImage.getImageContentType()), new SqlParameterValue(Types.DATE, logoImage.getModifiedDate()), new SqlParameterValue(Types.NUMERIC, logoImage.getLogoId())); if (is != null) updateImageImputStream(logoImage, is); }
From source file:org.apache.syncope.core.util.ImportExport.java
private void setParameters(final String tableName, final Attributes attrs, final Query query) { Map<String, Integer> colTypes = new HashMap<String, Integer>(); final Table table = getTable(tableName); for (int i = 0; i < attrs.getLength(); i++) { Integer colType = table.getColumn(QualifiedDBIdentifier.newColumn(attrs.getQName(i))).getType(); if (colType == null) { LOG.warn("No column type found for {}", attrs.getQName(i).toUpperCase()); colType = Types.VARCHAR; }/*from w w w . j av a 2 s. co m*/ switch (colType) { case Types.INTEGER: case Types.TINYINT: case Types.SMALLINT: try { query.setParameter(i + 1, Integer.valueOf(attrs.getValue(i))); } catch (NumberFormatException e) { LOG.error("Unparsable Integer '{}'", attrs.getValue(i)); query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.NUMERIC: case Types.DECIMAL: case Types.BIGINT: try { query.setParameter(i + 1, Long.valueOf(attrs.getValue(i))); } catch (NumberFormatException e) { LOG.error("Unparsable Long '{}'", attrs.getValue(i)); query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.DOUBLE: try { query.setParameter(i + 1, Double.valueOf(attrs.getValue(i))); } catch (NumberFormatException e) { LOG.error("Unparsable Double '{}'", attrs.getValue(i)); query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.REAL: case Types.FLOAT: try { query.setParameter(i + 1, Float.valueOf(attrs.getValue(i))); } catch (NumberFormatException e) { LOG.error("Unparsable Float '{}'", attrs.getValue(i)); query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.DATE: case Types.TIME: case Types.TIMESTAMP: try { query.setParameter(i + 1, DateUtils.parseDate(attrs.getValue(i), SyncopeConstants.DATE_PATTERNS), TemporalType.TIMESTAMP); } catch (ParseException e) { LOG.error("Unparsable Date '{}'", attrs.getValue(i)); query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.BIT: case Types.BOOLEAN: query.setParameter(i + 1, "1".equals(attrs.getValue(i)) ? Boolean.TRUE : Boolean.FALSE); break; case Types.BINARY: case Types.VARBINARY: case Types.LONGVARBINARY: try { query.setParameter(i + 1, Hex.decode(attrs.getValue(i))); } catch (IllegalArgumentException e) { query.setParameter(i + 1, attrs.getValue(i)); } break; case Types.BLOB: try { query.setParameter(i + 1, Hex.decode(attrs.getValue(i))); } catch (IllegalArgumentException e) { LOG.warn("Error decoding hex string to specify a blob parameter", e); query.setParameter(i + 1, attrs.getValue(i)); } catch (Exception e) { LOG.warn("Error creating a new blob parameter", e); } break; default: query.setParameter(i + 1, attrs.getValue(i)); } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleProjectBaseTable.java
public void createProjectBase(CFSecurityAuthorization Authorization, CFInternetProjectBaseBuff Buff) { final String S_ProcName = "createProjectBase"; ResultSet resultSet = null;//from w w w . ja va 2 s. c o m CallableStatement stmtCreateByPKey = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName() + ".crt_bprjdef( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;"); int argIdx = 1; stmtCreateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, ClassCode); stmtCreateByPKey.setLong(argIdx++, TenantId); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.execute(); resultSet = (ResultSet) stmtCreateByPKey.getObject(1); if (resultSet == null) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_bprjdef() did not return a result set"); } try { if (resultSet.next()) { CFInternetProjectBaseBuff createdBuff = unpackProjectBaseResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response, " + resultSet.getRow() + " rows selected"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "crt_bprjdef() did not return a valid result set"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } } }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmPgSql.CFCrmPgSqlSecUserTable.java
public void createSecUser(CFCrmAuthorization Authorization, CFCrmSecUserBuff Buff) { final String S_ProcName = "createSecUser"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//w ww . j av a 2 s . c o m ResultSet resultSet = null; try { String EMailAddress = Buff.getRequiredEMailAddress(); UUID DefaultDevSecUserId = Buff.getOptionalDefaultDevSecUserId(); String DefaultDevName = Buff.getOptionalDefaultDevName(); String HtmlPwHexHash = Buff.getRequiredHtmlPwHexHash(); String HtmlResetPwHexHash = Buff.getOptionalHtmlResetPwHexHash(); String AppPwHexHash = Buff.getOptionalAppPwHexHash(); String AppResetPwHexHash = Buff.getOptionalAppResetPwHexHash(); String MailtoEMailAddress = Buff.getRequiredMailtoEMailAddress(); UUID SecUserId = UUID.randomUUID(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerDbSchemaName() + ".sp_create_secuser( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "SUSR"); stmtCreateByPKey.setString(argIdx++, SecUserId.toString()); stmtCreateByPKey.setString(argIdx++, EMailAddress); if (DefaultDevSecUserId != null) { stmtCreateByPKey.setString(argIdx++, DefaultDevSecUserId.toString()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (DefaultDevName != null) { stmtCreateByPKey.setString(argIdx++, DefaultDevName); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setString(argIdx++, HtmlPwHexHash); if (HtmlResetPwHexHash != null) { stmtCreateByPKey.setString(argIdx++, HtmlResetPwHexHash); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (AppPwHexHash != null) { stmtCreateByPKey.setString(argIdx++, AppPwHexHash); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } if (AppResetPwHexHash != null) { stmtCreateByPKey.setString(argIdx++, AppResetPwHexHash); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR); } stmtCreateByPKey.setString(argIdx++, MailtoEMailAddress); resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFCrmSecUserBuff createdBuff = unpackSecUserResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId()); Buff.setRequiredEMailAddress(createdBuff.getRequiredEMailAddress()); Buff.setOptionalDefaultDevSecUserId(createdBuff.getOptionalDefaultDevSecUserId()); Buff.setOptionalDefaultDevName(createdBuff.getOptionalDefaultDevName()); Buff.setRequiredHtmlPwHexHash(createdBuff.getRequiredHtmlPwHexHash()); Buff.setOptionalHtmlResetPwHexHash(createdBuff.getOptionalHtmlResetPwHexHash()); Buff.setOptionalAppPwHexHash(createdBuff.getOptionalAppPwHexHash()); Buff.setOptionalAppResetPwHexHash(createdBuff.getOptionalAppResetPwHexHash()); Buff.setRequiredMailtoEMailAddress(createdBuff.getRequiredMailtoEMailAddress()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMySql.CFAsteriskMySqlDomainBaseTable.java
public void createDomainBase(CFSecurityAuthorization Authorization, CFInternetDomainBaseBuff Buff) { final String S_ProcName = "createDomainBase"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//ww w .jav a 2 s. c om ResultSet resultSet = null; try { String ClassCode = Buff.getClassCode(); long TenantId = Buff.getRequiredTenantId(); String Description = Buff.getOptionalDescription(); Connection cnx = schema.getCnx(); String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_bdomdef( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; 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); if (Description != null) { stmtCreateByPKey.setString(argIdx++, Description); } 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()) { CFInternetDomainBaseBuff createdBuff = unpackDomainBaseResultSetToBuff(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.setRequiredId(createdBuff.getRequiredId()); Buff.setOptionalDescription(createdBuff.getOptionalDescription()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } }