Example usage for java.sql CallableStatement getLong

List of usage examples for java.sql CallableStatement getLong

Introduction

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

Prototype

long getLong(String parameterName) throws SQLException;

Source Link

Document

Retrieves the value of a JDBC BIGINT parameter as a long in the Java programming language.

Usage

From source file:com.mobilewallet.common.dao.ForgotPasswordDAO.java

public Object[] getResetPasswordLink(String email, String uuid, String ip) {
    Connection connection = null;
    CallableStatement cstmt = null;
    Object[] obj = null;/*from   w  w w .  ja v  a2  s  . com*/
    int rvalue = -1;
    long userId = 0;
    try {
        connection = dataSource.getConnection();
        cstmt = connection.prepareCall("{call wp_forgot_pwd_reset_link(?,?,?,?,?)}");
        cstmt.setString(1, email);
        cstmt.setString(2, uuid);
        cstmt.setString(3, ip);
        cstmt.registerOutParameter(4, java.sql.Types.INTEGER);
        cstmt.registerOutParameter(5, java.sql.Types.INTEGER);

        cstmt.execute();

        rvalue = cstmt.getInt(4);
        userId = cstmt.getLong(5);

        obj = new Object[2];
        obj[0] = rvalue;
        obj[1] = userId;
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {

        try {
            if (cstmt != null) {
                cstmt.close();
            }
        } catch (Exception ex) {

        }
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (Exception ex) {

        }
    }
    return obj;
}

From source file:exifIndexer.MetadataReader.java

public static void walk(String path, boolean is_recursive) {

    File root = new File(path);
    File[] list = root.listFiles();
    String filePath;//from ww  w .j  av a  2s.com
    String fileName;
    String fileExt;
    String valueName;
    String tagName;
    String catName;
    Metadata metadata;
    long fileSize;
    long fileLastModified;
    java.util.Date utilDate;
    java.sql.Date sqlDate;

    String sql = "{ ? = call INSERTIMAGE(?,?,?,?,?) }";
    String sqlMetaData = "{ call INSERTMETADATA (?,?,?,?) }";

    CallableStatement statement;
    CallableStatement statementMeta;
    long result;

    if (list == null) {
        return;
    }

    for (File f : list) {
        if (f.isDirectory() && is_recursive) {
            walk(f.getAbsolutePath(), true);
        } else {

            filePath = FilenameUtils.getFullPath(f.getAbsolutePath());
            fileName = FilenameUtils.getBaseName(f.getName());
            fileExt = FilenameUtils.getExtension(f.getName());
            utilDate = new java.util.Date(f.lastModified());
            sqlDate = new java.sql.Date(utilDate.getTime());

            fileSize = f.length();

            try {
                metadata = ImageMetadataReader.readMetadata(f.getAbsoluteFile());
                try {
                    DBHandler db = new DBHandler();
                    db.openConnection();
                    Connection con = db.getCon();
                    // llamada al metodo insertar imagen SQL con (filePath,fileName,fileExtension,fileSize, fileLastModified)
                    statement = con.prepareCall(sql);
                    statement.setString(2, filePath);
                    statement.setString(3, fileName);
                    statement.setString(4, fileExt);
                    statement.setLong(5, fileSize);
                    statement.setDate(6, sqlDate);
                    statement.registerOutParameter(1, java.sql.Types.NUMERIC);
                    statement.execute();
                    result = statement.getLong(1);

                    // llamada al metodo insertar metadatos SQL con (idImg,valueName, tagName, catName)
                    for (Directory directory : metadata.getDirectories()) {
                        for (Tag tag : directory.getTags()) {

                            valueName = tag.getDescription();
                            tagName = tag.getTagName();
                            catName = directory.getName();

                            if (isNull(valueName) || isNull(tagName) || isNull(catName) || valueName.equals("")
                                    || tagName.equals("") || catName.equals("") || valueName.length() > 250
                                    || tagName.length() > 250 || catName.length() > 500) {
                                System.out.println("Exif row omitted.");
                                System.out.println("Omitting: [" + catName + "] " + tagName + " " + valueName);
                            } else {
                                statementMeta = con.prepareCall(sqlMetaData);
                                statementMeta.setLong(1, result);
                                statementMeta.setString(2, valueName);
                                statementMeta.setString(3, tagName);
                                statementMeta.setString(4, catName);
                                statementMeta.executeUpdate();
                            }
                        }
                    }
                    db.closeConnection();
                } catch (SQLException ex) {
                    System.err.println("Error with SQL command. \n" + ex);
                }
            } catch (ImageProcessingException e) {
                System.out.println("ImageProcessingException " + e);
            } catch (IOException e) {
                System.out.println("IOException " + e);
            }

        }

    }

}

From source file:com.mobilewallet.common.dao.RegisterDAO.java

public Object[] registerUser(String email, String fname, String lname, String dob, String gender, String pwd,
        String imei, String accounts, String country, String handsetModel, String androidVer, String emulator,
        String gcmId, String androidId, String refCode, String ip, String fbId) {
    Object[] obj = null;/* www.j  a v  a 2s .c om*/
    Connection con = null;
    CallableStatement cstmt = null;
    try {
        con = ds.getConnection();
        cstmt = con.prepareCall("{call REGISTER_USER(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
        cstmt.setString(1, email);
        cstmt.setString(2, fname);
        cstmt.setString(3, lname);
        cstmt.setString(4, dob);
        cstmt.setString(5, gender);
        cstmt.setString(6, pwd);
        cstmt.setString(7, imei);
        cstmt.setString(8, accounts);
        cstmt.setString(9, country);
        cstmt.setString(10, handsetModel);
        cstmt.setString(11, androidVer);
        cstmt.setString(12, emulator);
        cstmt.setString(13, gcmId);
        cstmt.setString(14, androidId);
        cstmt.setString(15, refCode);
        cstmt.setString(16, ip);
        cstmt.setString(17, fbId);
        cstmt.registerOutParameter(18, java.sql.Types.INTEGER);
        cstmt.registerOutParameter(19, java.sql.Types.VARCHAR);
        cstmt.registerOutParameter(20, java.sql.Types.INTEGER);
        cstmt.registerOutParameter(21, java.sql.Types.INTEGER);

        cstmt.execute();

        obj = new Object[4];
        obj[0] = cstmt.getInt(18);//rvalue
        obj[1] = cstmt.getString(19);//user ref code
        obj[2] = cstmt.getFloat(20);//balance
        obj[3] = cstmt.getLong(21);//user id
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        try {
            if (cstmt != null) {
                cstmt.close();
            }
        } catch (Exception ex) {

        }
        try {
            if (con != null) {
                con.close();
            }
        } catch (Exception ex) {

        }
    }
    return obj;
}

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

public long nextTldIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTldIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/* w w  w . j  a v a2s . c o  m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTldIdGen = null;
    try {
        String sql = "{ call sp_next_tldidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextTldIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextTldIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextTldIdGen.setLong(argIdx++, Id);
        stmtSelectNextTldIdGen.execute();
        long nextId = stmtSelectNextTldIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextTldIdGen != null) {
            try {
                stmtSelectNextTldIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTldIdGen = null;
        }
    }
}

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

public long nextTldIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextTldIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }//ww  w  . j a v a2 s .  c o  m
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTldIdGen = null;
    try {
        String sql = "{ call sp_next_tldidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextTldIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextTldIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextTldIdGen.setLong(argIdx++, Id);
        stmtSelectNextTldIdGen.execute();
        long nextId = stmtSelectNextTldIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextTldIdGen != null) {
            try {
                stmtSelectNextTldIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTldIdGen = null;
        }
    }
}

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

public long nextDomainIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextDomainIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }// ww w. j a  v a2  s .c om
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextDomainIdGen = null;
    try {
        String sql = "{ call sp_next_domainidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextDomainIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextDomainIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextDomainIdGen.setLong(argIdx++, Id);
        stmtSelectNextDomainIdGen.execute();
        long nextId = stmtSelectNextDomainIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextDomainIdGen != null) {
            try {
                stmtSelectNextDomainIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextDomainIdGen = null;
        }
    }
}

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

public long nextDomainIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextDomainIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from   w  ww. ja va2s.co m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextDomainIdGen = null;
    try {
        String sql = "{ call sp_next_domainidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextDomainIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextDomainIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextDomainIdGen.setLong(argIdx++, Id);
        stmtSelectNextDomainIdGen.execute();
        long nextId = stmtSelectNextDomainIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextDomainIdGen != null) {
            try {
                stmtSelectNextDomainIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextDomainIdGen = null;
        }
    }
}

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

public long nextTSecGroupMemberIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupMemberIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*w  w  w . j  av a  2s .  co m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupMemberIdGen = null;
    try {
        String sql = "{ call sp_next_tsecgroupmemberidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextTSecGroupMemberIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextTSecGroupMemberIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextTSecGroupMemberIdGen.setLong(argIdx++, Id);
        stmtSelectNextTSecGroupMemberIdGen.execute();
        long nextId = stmtSelectNextTSecGroupMemberIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextTSecGroupMemberIdGen != null) {
            try {
                stmtSelectNextTSecGroupMemberIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTSecGroupMemberIdGen = null;
        }
    }
}

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

public long nextTSecGroupIncludeIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupIncludeIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from   www  . ja  v  a  2  s . c  o  m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupIncludeIdGen = null;
    try {
        String sql = "{ call sp_next_tsecgroupincludeidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextTSecGroupIncludeIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextTSecGroupIncludeIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextTSecGroupIncludeIdGen.setLong(argIdx++, Id);
        stmtSelectNextTSecGroupIncludeIdGen.execute();
        long nextId = stmtSelectNextTSecGroupIncludeIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextTSecGroupIncludeIdGen != null) {
            try {
                stmtSelectNextTSecGroupIncludeIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTSecGroupIncludeIdGen = null;
        }
    }
}

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

public long nextTSecGroupMemberIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupMemberIdGen";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Not in a transaction");
    }/*from   w w w  .  j a v  a 2s. co  m*/
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupMemberIdGen = null;
    try {
        String sql = "{ call sp_next_tsecgroupmemberidgen( ?" + ", " + "?" + " ) }";
        stmtSelectNextTSecGroupMemberIdGen = cnx.prepareCall(sql);
        int argIdx = 1;
        stmtSelectNextTSecGroupMemberIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
        stmtSelectNextTSecGroupMemberIdGen.setLong(argIdx++, Id);
        stmtSelectNextTSecGroupMemberIdGen.execute();
        long nextId = stmtSelectNextTSecGroupMemberIdGen.getLong(1);
        return (nextId);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (stmtSelectNextTSecGroupMemberIdGen != null) {
            try {
                stmtSelectNextTSecGroupMemberIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTSecGroupMemberIdGen = null;
        }
    }
}