Example usage for java.sql Connection prepareCall

List of usage examples for java.sql Connection prepareCall

Introduction

In this page you can find the example usage for java.sql Connection prepareCall.

Prototype

CallableStatement prepareCall(String sql) throws SQLException;

Source Link

Document

Creates a CallableStatement object for calling database stored procedures.

Usage

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxOracle.CFEnSyntaxOracleAuditActionTable.java

public void deleteAuditAction(CFEnSyntaxAuthorization Authorization, CFEnSyntaxAuditActionBuff Buff) {
    final String S_ProcName = "deleteAuditAction";
    Connection cnx = schema.getCnx();
    CallableStatement stmtDeleteByPKey = null;
    try {/*from   ww w .java 2s .c  om*/
        short AuditActionId = Buff.getRequiredAuditActionId();
        stmtDeleteByPKey = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".dl_auditaction( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByPKey.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByPKey.setShort(argIdx++, AuditActionId);
        stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
        ;
        stmtDeleteByPKey.execute();
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtDeleteByPKey != null) {
            try {
                stmtDeleteByPKey.close();
            } catch (SQLException e) {
            }
            stmtDeleteByPKey = null;
        }
    }
}

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

public CFAccSecUserBuff readBuffByIdIdx(CFAccAuthorization Authorization, UUID SecUserId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;/*from  w  ww  .ja  v a  2 s  .c  om*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_secuserbyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setString(argIdx++, SecUserId.toString());
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAccSecUserBuff buff = unpackSecUserResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

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

public CFAstSecUserBuff readBuffByIdIdx(CFAstAuthorization Authorization, UUID SecUserId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;//from   w w  w  .  java 2 s.  com
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_secuserbyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setString(argIdx++, SecUserId.toString());
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAstSecUserBuff buff = unpackSecUserResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

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

public CFAccMimeTypeBuff readBuffByIdIdx(CFAccAuthorization Authorization, int MimeTypeId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;/*w w w.  ja  v  a  2  s  .  com*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_mimetypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setInt(argIdx++, MimeTypeId);
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAccMimeTypeBuff buff = unpackMimeTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleMimeTypeTable.java

public CFAstMimeTypeBuff readBuffByIdIdx(CFAstAuthorization Authorization, int MimeTypeId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;//from ww  w . ja v  a 2 s.com
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_mimetypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setInt(argIdx++, MimeTypeId);
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAstMimeTypeBuff buff = unpackMimeTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

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

public CFAstMimeTypeBuff readBuffByIdIdx(CFAstAuthorization Authorization, int MimeTypeId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;//from   w  ww.  j  a  v a2s  .  c  o  m
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_mimetypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setInt(argIdx++, MimeTypeId);
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAstMimeTypeBuff buff = unpackMimeTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswOracle.CFFswOracleMimeTypeTable.java

public CFFswMimeTypeBuff readBuffByIdIdx(CFFswAuthorization Authorization, int MimeTypeId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;/*from   ww w.  ja va 2  s . com*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByIdIdx = null;
    try {
        stmtReadBuffByIdIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_mimetypebyididx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByIdIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByIdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByIdIdx.setInt(argIdx++, MimeTypeId);
        stmtReadBuffByIdIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByIdIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFFswMimeTypeBuff buff = unpackMimeTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
    }
}

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

public CFAccServiceTypeBuff readBuffByUDescrIdx(CFAccAuthorization Authorization, String Description) {
    final String S_ProcName = "readBuffByUDescrIdx";
    ResultSet resultSet = null;//from  w w w.j a  v a 2 s . c o m
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByUDescrIdx = null;
    try {
        stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByUDescrIdx.setString(argIdx++, Description);
        stmtReadBuffByUDescrIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAccServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByUDescrIdx != null) {
            try {
                stmtReadBuffByUDescrIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByUDescrIdx = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstOracle.CFAstOracleServiceTypeTable.java

public CFAstServiceTypeBuff readBuffByUDescrIdx(CFAstAuthorization Authorization, String Description) {
    final String S_ProcName = "readBuffByUDescrIdx";
    ResultSet resultSet = null;/*from w w  w. ja  v a 2 s.  com*/
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByUDescrIdx = null;
    try {
        stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerSchemaDbName()
                + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByUDescrIdx.setString(argIdx++, Description);
        stmtReadBuffByUDescrIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAstServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByUDescrIdx != null) {
            try {
                stmtReadBuffByUDescrIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByUDescrIdx = null;
        }
    }
}

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

public CFAstServiceTypeBuff readBuffByUDescrIdx(CFAstAuthorization Authorization, String Description) {
    final String S_ProcName = "readBuffByUDescrIdx";
    ResultSet resultSet = null;// ww  w.jav a 2s  .com
    Connection cnx = schema.getCnx();
    CallableStatement stmtReadBuffByUDescrIdx = null;
    try {
        stmtReadBuffByUDescrIdx = cnx.prepareCall("begin " + schema.getLowerDbSchemaName()
                + ".rd_svctypebyudescridx( ?, ?, ?, ?, ?, ?" + ", " + "?" + " ); end;");
        int argIdx = 1;
        stmtReadBuffByUDescrIdx.registerOutParameter(argIdx++, OracleTypes.CURSOR);
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByUDescrIdx.setString(argIdx++, Description);
        stmtReadBuffByUDescrIdx.execute();
        resultSet = (ResultSet) stmtReadBuffByUDescrIdx.getObject(1);
        if (resultSet == null) {
            return (null);
        }
        try {
            if (resultSet.next()) {
                CFAstServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(resultSet);
                if (resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            return (null);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
        if (stmtReadBuffByUDescrIdx != null) {
            try {
                stmtReadBuffByUDescrIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByUDescrIdx = null;
        }
    }
}