Example usage for java.sql CallableStatement getInt

List of usage examples for java.sql CallableStatement getInt

Introduction

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

Prototype

int getInt(String parameterName) throws SQLException;

Source Link

Document

Retrieves the value of a JDBC INTEGER parameter as an int in the Java programming language.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSchema.java

public boolean isSystemUser(CFSecurityAuthorization Authorization) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                "Not in a transaction");
    }//  w w  w. j  a v  a2s .com
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_system_user( ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstMSSql.CFAstMSSqlSchema.java

public boolean isSystemUser(CFAstAuthorization Authorization) {
    final String S_ProcName = "isSystemUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//  w w w. ja v  a2s.c  o m
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_system_user ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMSSql.CFEnSyntaxMSSqlSchema.java

public boolean isSystemUser(CFEnSyntaxAuthorization Authorization) {
    final String S_ProcName = "isSystemUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from   w w w.j  av  a 2s.  c  om*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_system_user ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlSchema.java

public boolean isSystemUser(CFCrmAuthorization Authorization) {
    final String S_ProcName = "isSystemUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from w w  w  . j av  a 2s .  c  o  m*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_system_user ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java

public boolean isTenantUser(CFAstAuthorization Authorization, long tenantId, String secGroupName) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isTenantUser",
                "Not in a transaction");
    }//from  w  ww.ja va  2 s . c o m
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_tenant_user( ?, ?, ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, tenantId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isTenantUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstSybase.CFAstSybaseSchema.java

public boolean isClusterUser(CFAstAuthorization Authorization, long clusterId, String secGroupName) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isClusterUser",
                "Not in a transaction");
    }/*  w ww  . j  a v  a  2  s  .c  o m*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_cluster_user( ?, ?, ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, clusterId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isClusterUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskMSSql.CFAsteriskMSSqlSchema.java

public boolean isSystemUser(CFSecurityAuthorization Authorization) {
    final String S_ProcName = "isSystemUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from  w w  w  .j  a v  a 2 s.  c  om*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_system_user ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setString(2, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSchema.java

public boolean isTenantUser(CFSecurityAuthorization Authorization, long tenantId, String secGroupName) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isTenantUser",
                "Not in a transaction");
    }//  w  ww. j  a  v a2s .c  o m
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_tenant_user( ?, ?, ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, tenantId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isTenantUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSybase.CFAsteriskSybaseSchema.java

public boolean isClusterUser(CFSecurityAuthorization Authorization, long clusterId, String secGroupName) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isClusterUser",
                "Not in a transaction");
    }/*w w w  .  j a  v a2  s . c om*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "{ call sp_is_cluster_user( ?, ?, ?, ? ) }";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, clusterId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isClusterUser", e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstMSSql.CFAstMSSqlSchema.java

public boolean isTenantUser(CFAstAuthorization Authorization, long tenantId, String secGroupName) {
    final String S_ProcName = "isTenantUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from ww  w. j av a2s. c  o  m*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec sp_is_tenant_user ?, ?, ?, ?";
        stmtSecurityCheck = cnx.prepareCall(sql);
        stmtSecurityCheck.registerOutParameter(1, java.sql.Types.INTEGER);
        stmtSecurityCheck.setLong(2, tenantId);
        stmtSecurityCheck.setString(3, secGroupName);
        stmtSecurityCheck.setString(4, Authorization.getSecUserId().toString());
        stmtSecurityCheck.execute();
        int isAuthorized = stmtSecurityCheck.getInt(1);
        if (isAuthorized == 0) {
            return (false);
        } else {
            return (true);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSecurityCheck != null) {
            try {
                stmtSecurityCheck.close();
            } catch (SQLException e) {
            }
            stmtSecurityCheck = null;
        }
    }
}