Example usage for java.sql CallableStatement setNull

List of usage examples for java.sql CallableStatement setNull

Introduction

In this page you can find the example usage for java.sql CallableStatement setNull.

Prototype

void setNull(String parameterName, int sqlType) throws SQLException;

Source Link

Document

Sets the designated parameter to SQL NULL.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleSecUserTable.java

public void createSecUser(CFAstAuthorization Authorization, CFAstSecUserBuff Buff) {
    final String S_ProcName = "createSecUser";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from ww  w  .j  a  v a  2  s  .  c o m
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = 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();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".crt_secuser( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "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);
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_secuser() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAstSecUserBuff createdBuff = unpackSecUserResultSetToBuff(resultSet);
                if (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.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().newRuntimeException(getClass(), S_ProcName,
                    "crt_secuser() 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.cfacc.v2_0.CFAccOracle.CFAccOracleContactURLTable.java

public void updateContactURL(CFAccAuthorization Authorization, CFAccContactURLBuff Buff) {
    final String S_ProcName = "updateContactURL";
    ResultSet resultSet = null;//w ww  . j ava 2  s.c om
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFAccContactURLBuff> buffList = new LinkedList<CFAccContactURLBuff>();
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactURLId = Buff.getRequiredContactURLId();
        long ContactId = Buff.getRequiredContactId();
        Short URLProtocolId = Buff.getOptionalURLProtocolId();
        String Name = Buff.getRequiredName();
        String URL = Buff.getRequiredURL();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx.prepareCall(
                "begin " + schema.getLowerSchemaDbName() + ".upd_ctcurl( ?, ?, ?, ?, ?, ?, ?" + ", " + "?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "CURL");
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setLong(argIdx++, ContactURLId);
        stmtUpdateByPKey.setLong(argIdx++, ContactId);
        if (URLProtocolId != null) {
            stmtUpdateByPKey.setShort(argIdx++, URLProtocolId.shortValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtUpdateByPKey.setString(argIdx++, Name);
        stmtUpdateByPKey.setString(argIdx++, URL);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFAccContactURLBuff updatedBuff = unpackContactURLResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredContactId(updatedBuff.getRequiredContactId());
                    Buff.setOptionalURLProtocolId(updatedBuff.getOptionalURLProtocolId());
                    Buff.setRequiredName(updatedBuff.getRequiredName());
                    Buff.setRequiredURL(updatedBuff.getRequiredURL());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_ctcurl() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_ctcurl() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAttachmentTable.java

public void updateAttachment(CFAccAuthorization Authorization, CFAccAttachmentBuff Buff) {
    final String S_ProcName = "updateAttachment";
    ResultSet resultSet = null;// w  w  w  . ja  v  a2  s  .co m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFAccAttachmentBuff> buffList = new LinkedList<CFAccAttachmentBuff>();
    try {
        long TenantId = Buff.getRequiredTenantId();
        long AttachmentId = Buff.getRequiredAttachmentId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        Integer MimeTypeId = Buff.getOptionalMimeTypeId();
        String Attachment = Buff.getRequiredAttachment();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx.prepareCall(
                "begin " + schema.getLowerSchemaDbName() + ".upd_attchmnt( ?, ?, ?, ?, ?, ?, ?" + ", " + "?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "ATTC");
        stmtUpdateByPKey.setLong(argIdx++, TenantId);
        stmtUpdateByPKey.setLong(argIdx++, AttachmentId);
        stmtUpdateByPKey.setLong(argIdx++, ContactId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        if (MimeTypeId != null) {
            stmtUpdateByPKey.setInt(argIdx++, MimeTypeId.intValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.INTEGER);
        }
        stmtUpdateByPKey.setString(argIdx++, Attachment);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFAccAttachmentBuff updatedBuff = unpackAttachmentResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredContactId(updatedBuff.getRequiredContactId());
                    Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
                    Buff.setOptionalMimeTypeId(updatedBuff.getOptionalMimeTypeId());
                    Buff.setRequiredAttachment(updatedBuff.getRequiredAttachment());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_attchmnt() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_attchmnt() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleSecUserTable.java

public void updateSecUser(CFAstAuthorization Authorization, CFAstSecUserBuff Buff) {
    final String S_ProcName = "updateSecUser";
    ResultSet resultSet = null;// www .j a  va 2  s  . co m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFAstSecUserBuff> buffList = new LinkedList<CFAstSecUserBuff>();
    try {
        UUID SecUserId = Buff.getRequiredSecUserId();
        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();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".upd_secuser( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, "SUSR");
        stmtUpdateByPKey.setString(argIdx++, SecUserId.toString());
        stmtUpdateByPKey.setString(argIdx++, EMailAddress);
        if (DefaultDevSecUserId != null) {
            stmtUpdateByPKey.setString(argIdx++, DefaultDevSecUserId.toString());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (DefaultDevName != null) {
            stmtUpdateByPKey.setString(argIdx++, DefaultDevName);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtUpdateByPKey.setString(argIdx++, HtmlPwHexHash);
        if (HtmlResetPwHexHash != null) {
            stmtUpdateByPKey.setString(argIdx++, HtmlResetPwHexHash);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AppPwHexHash != null) {
            stmtUpdateByPKey.setString(argIdx++, AppPwHexHash);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AppResetPwHexHash != null) {
            stmtUpdateByPKey.setString(argIdx++, AppResetPwHexHash);
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtUpdateByPKey.setString(argIdx++, MailtoEMailAddress);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFAstSecUserBuff updatedBuff = unpackSecUserResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setRequiredEMailAddress(updatedBuff.getRequiredEMailAddress());
                    Buff.setOptionalDefaultDevSecUserId(updatedBuff.getOptionalDefaultDevSecUserId());
                    Buff.setOptionalDefaultDevName(updatedBuff.getOptionalDefaultDevName());
                    Buff.setRequiredHtmlPwHexHash(updatedBuff.getRequiredHtmlPwHexHash());
                    Buff.setOptionalHtmlResetPwHexHash(updatedBuff.getOptionalHtmlResetPwHexHash());
                    Buff.setOptionalAppPwHexHash(updatedBuff.getOptionalAppPwHexHash());
                    Buff.setOptionalAppResetPwHexHash(updatedBuff.getOptionalAppResetPwHexHash());
                    Buff.setRequiredMailtoEMailAddress(updatedBuff.getRequiredMailtoEMailAddress());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_secuser() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_secuser() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleSecSessionTable.java

public void createSecSession(CFSecurityAuthorization Authorization, CFSecuritySecSessionBuff Buff) {
    final String S_ProcName = "createSecSession";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  w  ww  .  j av a  2 s. c om*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        UUID SecUserId = Buff.getRequiredSecUserId();
        String SecDevName = Buff.getOptionalSecDevName();
        Calendar Start = Buff.getRequiredStart();
        Calendar Finish = Buff.getOptionalFinish();
        UUID SecProxyId = Buff.getOptionalSecProxyId();

        UUID SecSessionId = UUID.randomUUID();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall(
                "begin " + schema.getLowerDbSchemaName() + ".crt_secsess( ?, ?, ?, ?, ?, ?, ?" + ", " + "?"
                        + ", " + "?" + ", " + "?" + ", " + "to_timestamp( ?, 'YYYY-MM-DD HH24:MI:SS' )" + ", "
                        + "to_timestamp( ?, 'YYYY-MM-DD HH24:MI:SS' )" + ", " + "?" + " ); 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++, "SESS");
        stmtCreateByPKey.setString(argIdx++, SecSessionId.toString());
        stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
        if (SecDevName != null) {
            stmtCreateByPKey.setString(argIdx++, SecDevName);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setString(argIdx++, CFAsteriskOracleSchema.getTimestampString(Start));
        if (Finish != null) {
            stmtCreateByPKey.setString(argIdx++, CFAsteriskOracleSchema.getTimestampString(Finish));
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (SecProxyId != null) {
            stmtCreateByPKey.setString(argIdx++, SecProxyId.toString());
        } 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_secsess() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFSecuritySecSessionBuff createdBuff = unpackSecSessionResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredSecSessionId(createdBuff.getRequiredSecSessionId());
                Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId());
                Buff.setOptionalSecDevName(createdBuff.getOptionalSecDevName());
                Buff.setRequiredStart(createdBuff.getRequiredStart());
                Buff.setOptionalFinish(createdBuff.getOptionalFinish());
                Buff.setOptionalSecProxyId(createdBuff.getOptionalSecProxyId());
                Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            } 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_secsess() 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.cfasterisk.v2_1.CFAstOracle.CFAstOracleSecSessionTable.java

public void createSecSession(CFAstAuthorization Authorization, CFAstSecSessionBuff Buff) {
    final String S_ProcName = "createSecSession";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*w w  w.j  ava  2 s .c  o m*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        UUID SecUserId = Buff.getRequiredSecUserId();
        String SecDevName = Buff.getOptionalSecDevName();
        Calendar Start = Buff.getRequiredStart();
        Calendar Finish = Buff.getOptionalFinish();
        UUID SecProxyId = Buff.getOptionalSecProxyId();

        UUID SecSessionId = UUID.randomUUID();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall(
                "begin " + schema.getLowerDbSchemaName() + ".crt_secsess( ?, ?, ?, ?, ?, ?, ?" + ", " + "?"
                        + ", " + "?" + ", " + "?" + ", " + "to_timestamp( ?, 'YYYY-MM-DD HH24:MI:SS' )" + ", "
                        + "to_timestamp( ?, 'YYYY-MM-DD HH24:MI:SS' )" + ", " + "?" + " ); 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++, "SESS");
        stmtCreateByPKey.setString(argIdx++, SecSessionId.toString());
        stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
        if (SecDevName != null) {
            stmtCreateByPKey.setString(argIdx++, SecDevName);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        stmtCreateByPKey.setString(argIdx++, CFAstOracleSchema.getTimestampString(Start));
        if (Finish != null) {
            stmtCreateByPKey.setString(argIdx++, CFAstOracleSchema.getTimestampString(Finish));
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (SecProxyId != null) {
            stmtCreateByPKey.setString(argIdx++, SecProxyId.toString());
        } 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_secsess() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAstSecSessionBuff createdBuff = unpackSecSessionResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredSecSessionId(createdBuff.getRequiredSecSessionId());
                Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId());
                Buff.setOptionalSecDevName(createdBuff.getOptionalSecDevName());
                Buff.setRequiredStart(createdBuff.getRequiredStart());
                Buff.setOptionalFinish(createdBuff.getOptionalFinish());
                Buff.setOptionalSecProxyId(createdBuff.getOptionalSecProxyId());
                Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            } 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_secsess() 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.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleEnglishParseTable.java

public void updateEnglishParse(CFEnSyntaxAuthorization Authorization, CFEnSyntaxEnglishParseBuff Buff) {
    final String S_ProcName = "updateEnglishParse";
    ResultSet resultSet = null;//from   ww  w  . j a  v  a  2s  . c o m
    Connection cnx = schema.getCnx();
    CallableStatement stmtUpdateByPKey = null;
    List<CFEnSyntaxEnglishParseBuff> buffList = new LinkedList<CFEnSyntaxEnglishParseBuff>();
    try {
        String ClassCode = Buff.getClassCode();
        long Id = Buff.getRequiredId();
        Long ScopeId = Buff.getOptionalScopeId();
        String Name = Buff.getRequiredName();
        int Revision = Buff.getRequiredRevision();
        stmtUpdateByPKey = cnx
                .prepareCall("begin " + schema.getLowerDbSchemaName() + ".upd_enparse( ?, ?, ?, ?, ?, ?, ?"
                        + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "? ); end;");
        int argIdx = 1;
        stmtUpdateByPKey.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        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++, Id);
        if (ScopeId != null) {
            stmtUpdateByPKey.setLong(argIdx++, ScopeId.longValue());
        } else {
            stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        stmtUpdateByPKey.setString(argIdx++, Name);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        stmtUpdateByPKey.execute();
        resultSet = (ResultSet) stmtUpdateByPKey.getObject(1);
        if (resultSet != null) {
            try {
                if (resultSet.next()) {
                    CFEnSyntaxEnglishParseBuff updatedBuff = unpackEnglishParseResultSetToBuff(resultSet);
                    if (resultSet.next()) {
                        resultSet.last();
                        throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                                "Did not expect multi-record response, " + resultSet.getRow()
                                        + " rows selected");
                    }
                    Buff.setOptionalScopeId(updatedBuff.getOptionalScopeId());
                    Buff.setRequiredName(updatedBuff.getRequiredName());
                    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().newRuntimeException(getClass(), S_ProcName,
                        "upd_enparse() did not return a valid result cursor");
            } finally {
                if (resultSet != null) {
                    try {
                        resultSet.close();
                    } catch (SQLException e) {
                    }
                    resultSet = null;
                }
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "upd_enparse() did not return a result cursor");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccOracle.CFAccOracleAccountTable.java

public void createAccount(CFAccAuthorization Authorization, CFAccAccountBuff Buff) {
    final String S_ProcName = "createAccount";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  w w  w .java2  s. com
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        String AccountCode = Buff.getRequiredAccountCode();
        String Description = Buff.getRequiredDescription();
        short CurrencyId = Buff.getRequiredCurrencyId();
        BigDecimal Balance = Buff.getRequiredBalance();
        Long RollupTenantId = Buff.getOptionalRollupTenantId();
        Long RollupAccountId = Buff.getOptionalRollupAccountId();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall(
                "begin " + schema.getLowerSchemaDbName() + ".crt_acct( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", "
                        + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "ACCT");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setString(argIdx++, AccountCode);
        stmtCreateByPKey.setString(argIdx++, Description);
        stmtCreateByPKey.setShort(argIdx++, CurrencyId);
        stmtCreateByPKey.setBigDecimal(argIdx++, Balance);
        if (RollupTenantId != null) {
            stmtCreateByPKey.setLong(argIdx++, RollupTenantId.longValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        if (RollupAccountId != null) {
            stmtCreateByPKey.setLong(argIdx++, RollupAccountId.longValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT);
        }
        stmtCreateByPKey.execute();
        resultSet = (ResultSet) stmtCreateByPKey.getObject(1);
        if (resultSet == null) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "crt_acct() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccAccountBuff createdBuff = unpackAccountResultSetToBuff(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.setRequiredAccountCode(createdBuff.getRequiredAccountCode());
                Buff.setRequiredDescription(createdBuff.getRequiredDescription());
                Buff.setRequiredCurrencyId(createdBuff.getRequiredCurrencyId());
                Buff.setRequiredBalance(createdBuff.getRequiredBalance());
                Buff.setOptionalRollupTenantId(createdBuff.getOptionalRollupTenantId());
                Buff.setOptionalRollupAccountId(createdBuff.getOptionalRollupAccountId());
                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_acct() 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.cfacc.v2_0.CFAccOracle.CFAccOracleContactTable.java

public void createContact(CFAccAuthorization Authorization, CFAccContactBuff Buff) {
    final String S_ProcName = "createContact";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  w  w  w  .  j av  a 2 s .  com*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactListId = Buff.getRequiredContactListId();
        Short ISOTimezoneId = Buff.getOptionalISOTimezoneId();
        String FullName = Buff.getRequiredFullName();
        String LastName = Buff.getOptionalLastName();
        String FirstName = Buff.getOptionalFirstName();
        String Custom = Buff.getOptionalCustom();
        String Custom2 = Buff.getOptionalCustom2();
        String Custom3 = Buff.getOptionalCustom3();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_contact( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "CTC");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactListId);
        if (ISOTimezoneId != null) {
            stmtCreateByPKey.setShort(argIdx++, ISOTimezoneId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        stmtCreateByPKey.setString(argIdx++, FullName);
        if (LastName != null) {
            stmtCreateByPKey.setString(argIdx++, LastName);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (FirstName != null) {
            stmtCreateByPKey.setString(argIdx++, FirstName);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (Custom != null) {
            stmtCreateByPKey.setString(argIdx++, Custom);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (Custom2 != null) {
            stmtCreateByPKey.setString(argIdx++, Custom2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (Custom3 != null) {
            stmtCreateByPKey.setString(argIdx++, Custom3);
        } 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_contact() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccContactBuff createdBuff = unpackContactResultSetToBuff(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.setRequiredContactId(createdBuff.getRequiredContactId());
                Buff.setRequiredContactListId(createdBuff.getRequiredContactListId());
                Buff.setOptionalISOTimezoneId(createdBuff.getOptionalISOTimezoneId());
                Buff.setRequiredFullName(createdBuff.getRequiredFullName());
                Buff.setOptionalLastName(createdBuff.getOptionalLastName());
                Buff.setOptionalFirstName(createdBuff.getOptionalFirstName());
                Buff.setOptionalCustom(createdBuff.getOptionalCustom());
                Buff.setOptionalCustom2(createdBuff.getOptionalCustom2());
                Buff.setOptionalCustom3(createdBuff.getOptionalCustom3());
                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_contact() 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.cfacc.v2_0.CFAccOracle.CFAccOracleAddressTable.java

public void createAddress(CFAccAuthorization Authorization, CFAccAddressBuff Buff) {
    final String S_ProcName = "createAddress";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/* w w  w. j av  a  2s.c  om*/
    ResultSet resultSet = null;
    CallableStatement stmtCreateByPKey = null;
    try {
        long TenantId = Buff.getRequiredTenantId();
        long ContactId = Buff.getRequiredContactId();
        String Description = Buff.getRequiredDescription();
        String AddrLine1 = Buff.getOptionalAddrLine1();
        String AddrLine2 = Buff.getOptionalAddrLine2();
        String City = Buff.getOptionalCity();
        String State = Buff.getOptionalState();
        Short CountryId = Buff.getOptionalCountryId();
        String Zip = Buff.getOptionalZip();
        Connection cnx = schema.getCnx();
        stmtCreateByPKey = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".crt_address( ?, ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", "
                + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " ); 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++, "ADR");
        stmtCreateByPKey.setLong(argIdx++, TenantId);
        stmtCreateByPKey.setLong(argIdx++, ContactId);
        stmtCreateByPKey.setString(argIdx++, Description);
        if (AddrLine1 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine1);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (AddrLine2 != null) {
            stmtCreateByPKey.setString(argIdx++, AddrLine2);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (City != null) {
            stmtCreateByPKey.setString(argIdx++, City);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (State != null) {
            stmtCreateByPKey.setString(argIdx++, State);
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
        }
        if (CountryId != null) {
            stmtCreateByPKey.setShort(argIdx++, CountryId.shortValue());
        } else {
            stmtCreateByPKey.setNull(argIdx++, java.sql.Types.SMALLINT);
        }
        if (Zip != null) {
            stmtCreateByPKey.setString(argIdx++, Zip);
        } 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_address() did not return a result set");
        }
        try {
            if (resultSet.next()) {
                CFAccAddressBuff createdBuff = unpackAddressResultSetToBuff(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.setRequiredAddressId(createdBuff.getRequiredAddressId());
                Buff.setRequiredContactId(createdBuff.getRequiredContactId());
                Buff.setRequiredDescription(createdBuff.getRequiredDescription());
                Buff.setOptionalAddrLine1(createdBuff.getOptionalAddrLine1());
                Buff.setOptionalAddrLine2(createdBuff.getOptionalAddrLine2());
                Buff.setOptionalCity(createdBuff.getOptionalCity());
                Buff.setOptionalState(createdBuff.getOptionalState());
                Buff.setOptionalCountryId(createdBuff.getOptionalCountryId());
                Buff.setOptionalZip(createdBuff.getOptionalZip());
                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_address() 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;
        }
    }
}