Example usage for java.sql Types INTEGER

List of usage examples for java.sql Types INTEGER

Introduction

In this page you can find the example usage for java.sql Types INTEGER.

Prototype

int INTEGER

To view the source code for java.sql Types INTEGER.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type INTEGER.

Usage

From source file:com.flexive.ejb.beans.BriefcaseEngineBean.java

/**
 * {@inheritDoc}//w  w  w.j  a  v a  2  s .c  o  m
 */
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void addItemData(long briefcaseId, BriefcaseItemData itemData) throws FxApplicationException {
    if (itemData == null)
        return;
    Briefcase br = load(briefcaseId); // check read permissions
    Connection con = null;
    PreparedStatement stmt = null;
    try {
        con = Database.getDbConnection();
        // check if the item actually exists
        stmt = con.prepareStatement(
                "SELECT COUNT(*) FROM " + TBL_BRIEFCASE_DATA + " WHERE briefcase_id=? AND id=?");
        stmt.setLong(1, briefcaseId);
        stmt.setLong(2, itemData.getId());
        ResultSet rs = stmt.executeQuery();
        if (rs == null || !rs.next() || rs.getLong(1) != 1)
            throw new FxNotFoundException(LOG, "ex.briefcase.notFound.item", itemData.getId(), br.getName());
        stmt.close();
        stmt = con.prepareStatement(
                "SELECT MAX(pos) FROM " + TBL_BRIEFCASE_DATA_ITEM + " WHERE briefcase_id=? AND id=?");
        stmt.setLong(1, briefcaseId);
        stmt.setLong(2, itemData.getId());
        rs = stmt.executeQuery();
        int pos = rs.next() ? rs.getInt(1) : 0;
        stmt.close();
        stmt = con.prepareStatement("INSERT INTO " + TBL_BRIEFCASE_DATA_ITEM
                + "(briefcase_id, id, pos, intflag1, intflag2, intflag3, longflag1, longflag2, metadata) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
        stmt.setLong(1, briefcaseId);
        stmt.setLong(2, itemData.getId());
        stmt.setLong(3, ++pos);
        if (itemData.isIntFlagSet(1))
            stmt.setInt(4, itemData.getIntFlag1());
        else
            stmt.setNull(4, Types.INTEGER);
        if (itemData.isIntFlagSet(2))
            stmt.setInt(5, itemData.getIntFlag2());
        else
            stmt.setNull(5, Types.INTEGER);
        if (itemData.isIntFlagSet(3))
            stmt.setInt(6, itemData.getIntFlag3());
        else
            stmt.setNull(6, Types.INTEGER);
        if (itemData.isLongFlagSet(1))
            stmt.setLong(7, itemData.getLongFlag1());
        else
            stmt.setNull(7, Types.BIGINT);
        if (itemData.isLongFlagSet(2))
            stmt.setLong(8, itemData.getLongFlag2());
        else
            stmt.setNull(8, Types.BIGINT);
        stmt.setString(9, itemData.getMetaData());
        stmt.executeUpdate();
    } catch (Exception e) {
        EJBUtils.rollback(ctx);
        throw new FxUpdateException(LOG, e, "ex.briefcase.addItemData", br.getName(), itemData.getId(),
                e.getMessage());
    } finally {
        Database.closeObjects(BriefcaseEngineBean.class, con, stmt);
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_1.CFInternetMSSql.CFInternetMSSqlSchema.java

public boolean isClusterUser(CFInternetAuthorization Authorization, long clusterId, String secGroupName) {
    final String S_ProcName = "isClusterUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*  ww w.  j a  va2s  .  co m*/
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec 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(), S_ProcName, 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  ww  .  j  a va2  s  .co  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.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");
    }/*  w  ww  .  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.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");
    }//  www.j a v  a2  s . com
    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.cfinternet.v2_1.CFInternetMSSql.CFInternetMSSqlSchema.java

public boolean isTenantUser(CFInternetAuthorization Authorization, long tenantId, String secGroupName) {
    final String S_ProcName = "isTenantUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//w w  w  .  j  a  va  2  s.com
    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;
        }
    }
}

From source file:com.squid.kraken.v4.caching.redis.datastruct.RawMatrix.java

public static String getJavaDatatype(int colType) {

    switch (colType) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
        return "java.lang.String";

    case Types.NUMERIC:
    case Types.DECIMAL:
        return "java.math.BigDecimal";

    case Types.BIT:
        return "boolean";

    case Types.TINYINT:
        return "byte";

    case Types.SMALLINT:
        return "short";

    case Types.INTEGER:
        return "int";

    case Types.BIGINT:
        return "long";

    case Types.REAL:
        return "float";

    case Types.FLOAT:
    case Types.DOUBLE:
        return "double";

    case Types.BINARY:
    case Types.VARBINARY:
    case Types.LONGVARBINARY:
        return "byte[]";

    case Types.DATE:
        return "java.sql.Date";

    case Types.TIME:
        return "java.sql.Time";

    case Types.TIMESTAMP:
        return "java.sql.Timestamp";

    case Types.OTHER:
        return "java.lang.Object";
    default://from  w w  w . ja  v a 2s  . co m
        return null;
    }
}

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

public boolean isClusterUser(CFAstAuthorization Authorization, long clusterId, String secGroupName) {
    final String S_ProcName = "isClusterUser";
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//from   w w  w  .  j  a va2s  . com
    CallableStatement stmtSecurityCheck = null;
    try {
        final String sql = "exec 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(), 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");
    }/*w w w .j av  a2 s  .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 isSystemUser(CFAstAuthorization Authorization) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                "Not in a transaction");
    }//  w  ww.jav  a  2 s  . co m
    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;
        }
    }
}