Example usage for java.sql ResultSet getDate

List of usage examples for java.sql ResultSet getDate

Introduction

In this page you can find the example usage for java.sql ResultSet getDate.

Prototype

java.sql.Date getDate(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.

Usage

From source file:com.mimp.hibernate.HiberNna.java

public ArrayList<Nna> ListaNnaSeguimiento(String clasificacion) {
    Session session = sessionFactory.getCurrentSession();
    final String clasif = clasificacion;
    final ArrayList<Nna> allNna = new ArrayList();
    final ArrayList<Nna> allNnaAux = new ArrayList();
    final ArrayList<Nna> allNnaFinal = new ArrayList();

    Work work = new Work() {
        @Override//from ww w . j  a  v  a2  s .co  m
        public void execute(Connection connection) throws SQLException {
            ExpedienteNna expnna;
            Nna tempnna;
            Designacion desig;

            EstudioCaso est;

            String hql = "{call HN_GET_NNA_SEG(?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.registerOutParameter(1, OracleTypes.CURSOR);
            statement.execute();

            temp = (ResultSet) statement.getObject(1);

            while (temp.next()) {
                tempnna = new Nna();
                tempnna.setIdnna(temp.getLong(1));
                tempnna.setNombre(temp.getString(2));
                tempnna.setApellidoP(temp.getString(3));
                tempnna.setApellidoM(temp.getString(4));
                tempnna.setSexo(temp.getString(5));
                tempnna.setFechaNacimiento(temp.getDate(6));
                tempnna.setEdadAnhos(temp.getShort(7));
                tempnna.setEdadMeses(temp.getShort(8));
                tempnna.setActaNacimiento(temp.getShort(9));
                tempnna.setCondicionSalud(temp.getString(10));
                tempnna.setDepartamentoNacimiento(temp.getString(11));
                tempnna.setProvinciaNacimiento(temp.getString(12));
                tempnna.setDistritoNacimiento(temp.getString(13));
                tempnna.setPaisNacimiento(temp.getString(14));
                tempnna.setLugarNac(temp.getString(15));
                tempnna.setFechaResolAbandono(temp.getDate(16));
                tempnna.setFechaResolConsentida(temp.getDate(17));
                tempnna.setClasificacion(temp.getString(18));
                tempnna.setIncesto(temp.getShort(19));
                tempnna.setMental(temp.getShort(20));
                tempnna.setEpilepsia(temp.getShort(21));
                tempnna.setAbuso(temp.getShort(22));
                tempnna.setSifilis(temp.getShort(23));
                tempnna.setSeguiMedico(temp.getShort(24));
                tempnna.setOperacion(temp.getShort(25));
                tempnna.setHiperactivo(temp.getShort(26));
                tempnna.setEspecial(temp.getShort(27));
                tempnna.setEnfermo(temp.getShort(28));
                tempnna.setMayor(temp.getShort(29));
                tempnna.setAdolescente(temp.getShort(30));
                tempnna.setHermano(temp.getShort(31));
                tempnna.setNn(temp.getShort(32));
                tempnna.setObservaciones(temp.getString(33));
                tempnna.setNResolAband(temp.getString(34));
                tempnna.setNResolCons(temp.getString(35));
                try {
                    expnna = getExpNna(temp.getLong(1));
                    if (expnna.getIdexpedienteNna() != 0) {
                        Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>();
                        listexp.add(expnna);
                        tempnna.setExpedienteNnas(listexp);
                    }
                } catch (Exception e) {

                }
                allNnaAux.add(tempnna);
            }
            statement.close();
            temp.close();

            //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO
            for (Nna auxnna : allNnaAux) {
                Set<Designacion> listDesig = new HashSet<Designacion>();
                String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, auxnna.getIdnna());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);
                while (rs2.next()) {
                    desig = new Designacion();
                    desig.setIddesignacion(rs2.getLong(1));
                    desig.setNDesignacion(rs2.getString(5));
                    desig.setPrioridad(rs2.getLong(6));
                    desig.setFechaPropuesta(rs2.getDate(7));
                    desig.setFechaConsejo(rs2.getDate(8));
                    desig.setAceptacionConsejo(rs2.getShort(9));
                    desig.setTipoPropuesta(rs2.getString(10));
                    desig.setObs(rs2.getString(11));
                    listDesig.add(desig);
                }
                auxnna.setDesignacions(listDesig);
                allNna.add(auxnna);
                statement2.close();
                rs2.close();
            }

            for (Nna auxnna : allNna) {
                if (auxnna.getClasificacion().equals("prioritario")) {
                    Set<EstudioCaso> listEst = new HashSet<EstudioCaso>();
                    String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}";
                    CallableStatement statement3 = connection.prepareCall(hql3);
                    statement3.setLong(1, auxnna.getIdnna());
                    statement3.registerOutParameter(2, OracleTypes.CURSOR);
                    statement3.execute();

                    ResultSet rs3 = (ResultSet) statement3.getObject(2);
                    while (rs3.next()) {
                        est = new EstudioCaso();
                        est.setIdestudioCaso(rs3.getLong(1));
                        est.setOrden(rs3.getString(4));
                        est.setFechaEstudio(rs3.getDate(5));
                        est.setFechaSolAdop(rs3.getDate(6));
                        est.setResultado(rs3.getString(7));
                        est.setPrioridad(rs3.getLong(8));
                        est.setNSolicitud(rs3.getLong(9));
                        listEst.add(est);
                    }
                    auxnna.setEstudioCasos(listEst);
                    statement3.close();
                    rs3.close();
                }
                allNnaFinal.add(auxnna);
            }

            //METODO BUBBLESORT PARA ORDENAR POR CODIGO
            if (clasif.equals("prioritario")) {
                Nna auxnna2;
                int n = allNnaFinal.size();
                for (int i = 0; i < n - 1; i++) {
                    for (int j = i; j < n - 1; j++) {
                        if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) {
                            if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) {
                                auxnna2 = allNnaFinal.get(i);
                                allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                allNnaFinal.set(j + 1, auxnna2);
                            } else {
                                String apellidoPrev = "";
                                String apellidoNext = "";
                                try {
                                    apellidoPrev = allNnaFinal.get(i).getApellidoP();
                                    if (apellidoPrev == null) {
                                        apellidoPrev = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoPrev = "";
                                }
                                try {
                                    apellidoNext = allNnaFinal.get(j + 1).getApellidoP();
                                    if (apellidoNext == null) {
                                        apellidoNext = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoNext = "";
                                }
                                if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) {
                                    auxnna2 = allNnaFinal.get(i);
                                    allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                    allNnaFinal.set(j + 1, auxnna2);
                                }
                            }
                        } else {
                            Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas();
                            Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas();
                            if (!listExp2.isEmpty()) {
                                for (ExpedienteNna exp1 : listExp1) {
                                    for (ExpedienteNna exp2 : listExp2) {
                                        String codant = exp1.getCodigoReferencia();
                                        String codpost = exp2.getCodigoReferencia();
                                        if (codant == null) {
                                            codant = "";
                                        }
                                        if (codpost == null) {
                                            codpost = "";
                                        }
                                        if (codant.compareToIgnoreCase(codpost) > 0) {
                                            auxnna2 = allNnaFinal.get(i);
                                            allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                            allNnaFinal.set(j + 1, auxnna2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    session.doWork(work);

    return allNnaFinal;
}

From source file:com.mimp.hibernate.HiberNna.java

public ArrayList<Nna> ListaNna(String clasificacion) {
    Session session = sessionFactory.getCurrentSession();
    final String clasif = clasificacion;
    final ArrayList<Nna> allNna = new ArrayList();
    final ArrayList<Nna> allNnaAux = new ArrayList();
    final ArrayList<Nna> allNnaFinal = new ArrayList();

    Work work = new Work() {
        @Override//  ww w  . j  ava  2  s  .  com
        public void execute(Connection connection) throws SQLException {
            ExpedienteNna expnna;
            Nna tempnna;
            Designacion desig;

            EstudioCaso est;

            String hql = "{call HN_GET_NNA_CLAS(?,?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.setString(1, clasif);
            statement.registerOutParameter(2, OracleTypes.CURSOR);
            statement.execute();

            temp = (ResultSet) statement.getObject(2);

            while (temp.next()) {
                tempnna = new Nna();
                tempnna.setIdnna(temp.getLong(1));
                tempnna.setNombre(temp.getString(2));
                tempnna.setApellidoP(temp.getString(3));
                tempnna.setApellidoM(temp.getString(4));
                tempnna.setSexo(temp.getString(5));
                tempnna.setFechaNacimiento(temp.getDate(6));
                tempnna.setEdadAnhos(temp.getShort(7));
                tempnna.setEdadMeses(temp.getShort(8));
                tempnna.setActaNacimiento(temp.getShort(9));
                tempnna.setCondicionSalud(temp.getString(10));
                tempnna.setDepartamentoNacimiento(temp.getString(11));
                tempnna.setProvinciaNacimiento(temp.getString(12));
                tempnna.setDistritoNacimiento(temp.getString(13));
                tempnna.setPaisNacimiento(temp.getString(14));
                tempnna.setLugarNac(temp.getString(15));
                tempnna.setFechaResolAbandono(temp.getDate(16));
                tempnna.setFechaResolConsentida(temp.getDate(17));
                tempnna.setClasificacion(temp.getString(18));
                tempnna.setIncesto(temp.getShort(19));
                tempnna.setMental(temp.getShort(20));
                tempnna.setEpilepsia(temp.getShort(21));
                tempnna.setAbuso(temp.getShort(22));
                tempnna.setSifilis(temp.getShort(23));
                tempnna.setSeguiMedico(temp.getShort(24));
                tempnna.setOperacion(temp.getShort(25));
                tempnna.setHiperactivo(temp.getShort(26));
                tempnna.setEspecial(temp.getShort(27));
                tempnna.setEnfermo(temp.getShort(28));
                tempnna.setMayor(temp.getShort(29));
                tempnna.setAdolescente(temp.getShort(30));
                tempnna.setHermano(temp.getShort(31));
                tempnna.setNn(temp.getShort(32));
                tempnna.setObservaciones(temp.getString(33));
                tempnna.setNResolAband(temp.getString(34));
                tempnna.setNResolCons(temp.getString(35));
                try {
                    expnna = getExpNna(temp.getLong(1));
                    if (expnna.getIdexpedienteNna() != 0) {
                        Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>();
                        listexp.add(expnna);
                        tempnna.setExpedienteNnas(listexp);
                    }
                } catch (Exception e) {

                }
                allNnaAux.add(tempnna);
            }
            statement.close();
            temp.close();

            //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO
            for (Nna auxnna : allNnaAux) {
                Set<Designacion> listDesig = new HashSet<Designacion>();
                String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, auxnna.getIdnna());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);
                while (rs2.next()) {
                    desig = new Designacion();
                    desig.setIddesignacion(rs2.getLong(1));
                    desig.setNDesignacion(rs2.getString(5));
                    desig.setPrioridad(rs2.getLong(6));
                    desig.setFechaPropuesta(rs2.getDate(7));
                    desig.setFechaConsejo(rs2.getDate(8));
                    desig.setAceptacionConsejo(rs2.getShort(9));
                    desig.setTipoPropuesta(rs2.getString(10));
                    desig.setObs(rs2.getString(11));
                    listDesig.add(desig);
                }
                auxnna.setDesignacions(listDesig);
                allNna.add(auxnna);
                statement2.close();
                rs2.close();
            }

            for (Nna auxnna : allNna) {
                if (auxnna.getClasificacion().equals("prioritario")) {
                    Set<EstudioCaso> listEst = new HashSet<EstudioCaso>();
                    String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}";
                    CallableStatement statement3 = connection.prepareCall(hql3);
                    statement3.setLong(1, auxnna.getIdnna());
                    statement3.registerOutParameter(2, OracleTypes.CURSOR);
                    statement3.execute();

                    ResultSet rs3 = (ResultSet) statement3.getObject(2);
                    while (rs3.next()) {
                        est = new EstudioCaso();
                        est.setIdestudioCaso(rs3.getLong(1));
                        est.setOrden(rs3.getString(4));
                        est.setFechaEstudio(rs3.getDate(5));
                        est.setFechaSolAdop(rs3.getDate(6));
                        est.setResultado(rs3.getString(7));
                        est.setPrioridad(rs3.getLong(8));
                        est.setNSolicitud(rs3.getLong(9));
                        listEst.add(est);
                    }
                    auxnna.setEstudioCasos(listEst);
                    statement3.close();
                    rs3.close();
                }
                allNnaFinal.add(auxnna);
            }

            //METODO BUBBLESORT PARA ORDENAR POR CODIGO
            if (clasif.equals("prioritario")) {
                Nna auxnna2;
                int n = allNnaFinal.size();
                for (int i = 0; i < n - 1; i++) {
                    for (int j = i; j < n - 1; j++) {
                        if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) {
                            if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) {
                                auxnna2 = allNnaFinal.get(i);
                                allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                allNnaFinal.set(j + 1, auxnna2);
                            } else {
                                String apellidoPrev = "";
                                String apellidoNext = "";
                                try {
                                    apellidoPrev = allNnaFinal.get(i).getApellidoP();
                                    if (apellidoPrev == null) {
                                        apellidoPrev = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoPrev = "";
                                }
                                try {
                                    apellidoNext = allNnaFinal.get(j + 1).getApellidoP();
                                    if (apellidoNext == null) {
                                        apellidoNext = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoNext = "";
                                }
                                if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) {
                                    auxnna2 = allNnaFinal.get(i);
                                    allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                    allNnaFinal.set(j + 1, auxnna2);
                                }
                            }
                        } else {
                            Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas();
                            Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas();
                            if (!listExp2.isEmpty()) {
                                for (ExpedienteNna exp1 : listExp1) {
                                    for (ExpedienteNna exp2 : listExp2) {
                                        String codant = exp1.getCodigoReferencia();
                                        String codpost = exp2.getCodigoReferencia();
                                        if (codant == null) {
                                            codant = "";
                                        }
                                        if (codpost == null) {
                                            codpost = "";
                                        }
                                        if (codant.compareToIgnoreCase(codpost) > 0) {
                                            auxnna2 = allNnaFinal.get(i);
                                            allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                            allNnaFinal.set(j + 1, auxnna2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    session.doWork(work);

    return allNnaFinal;
}

From source file:com.mimp.hibernate.HiberNna.java

public ArrayList<Nna> ListaNnaPrioritarios(String clasificacion) {
    Session session = sessionFactory.getCurrentSession();
    final String clasif = clasificacion;
    final ArrayList<Nna> allNna = new ArrayList();
    final ArrayList<Nna> allNnaAux = new ArrayList();
    final ArrayList<Nna> allNnaFinal = new ArrayList();

    Work work = new Work() {
        @Override//from  w  w  w . jav  a 2  s.c o m
        public void execute(Connection connection) throws SQLException {
            ExpedienteNna expnna;
            Nna tempnna;
            Designacion desig;

            EstudioCaso est;

            String hql = "{call HN_GET_NNA_PRIO(?)}";
            CallableStatement statement = connection.prepareCall(hql);
            statement.registerOutParameter(1, OracleTypes.CURSOR);
            statement.execute();

            temp = (ResultSet) statement.getObject(1);

            while (temp.next()) {
                tempnna = new Nna();
                tempnna.setIdnna(temp.getLong(1));
                tempnna.setNombre(temp.getString(2));
                tempnna.setApellidoP(temp.getString(3));
                tempnna.setApellidoM(temp.getString(4));
                tempnna.setSexo(temp.getString(5));
                tempnna.setFechaNacimiento(temp.getDate(6));
                tempnna.setEdadAnhos(temp.getShort(7));
                tempnna.setEdadMeses(temp.getShort(8));
                tempnna.setActaNacimiento(temp.getShort(9));
                tempnna.setCondicionSalud(temp.getString(10));
                tempnna.setDepartamentoNacimiento(temp.getString(11));
                tempnna.setProvinciaNacimiento(temp.getString(12));
                tempnna.setDistritoNacimiento(temp.getString(13));
                tempnna.setPaisNacimiento(temp.getString(14));
                tempnna.setLugarNac(temp.getString(15));
                tempnna.setFechaResolAbandono(temp.getDate(16));
                tempnna.setFechaResolConsentida(temp.getDate(17));
                tempnna.setClasificacion(temp.getString(18));
                tempnna.setIncesto(temp.getShort(19));
                tempnna.setMental(temp.getShort(20));
                tempnna.setEpilepsia(temp.getShort(21));
                tempnna.setAbuso(temp.getShort(22));
                tempnna.setSifilis(temp.getShort(23));
                tempnna.setSeguiMedico(temp.getShort(24));
                tempnna.setOperacion(temp.getShort(25));
                tempnna.setHiperactivo(temp.getShort(26));
                tempnna.setEspecial(temp.getShort(27));
                tempnna.setEnfermo(temp.getShort(28));
                tempnna.setMayor(temp.getShort(29));
                tempnna.setAdolescente(temp.getShort(30));
                tempnna.setHermano(temp.getShort(31));
                tempnna.setNn(temp.getShort(32));
                tempnna.setObservaciones(temp.getString(33));
                tempnna.setNResolAband(temp.getString(34));
                tempnna.setNResolCons(temp.getString(35));
                try {
                    expnna = getExpNna(temp.getLong(1));
                    if (expnna.getIdexpedienteNna() != 0) {
                        Set<ExpedienteNna> listexp = new HashSet<ExpedienteNna>();
                        listexp.add(expnna);
                        tempnna.setExpedienteNnas(listexp);
                    }
                } catch (Exception e) {

                }
                allNnaAux.add(tempnna);
            }
            statement.close();
            temp.close();

            //AQUI DESIGNACIONES Y ESTUDIO DE CASOS EN CASO SEA PRIORITARIO
            for (Nna auxnna : allNnaAux) {
                Set<Designacion> listDesig = new HashSet<Designacion>();
                String hql2 = "{call HN_GET_DESIGNACIONES(?,?)}";
                CallableStatement statement2 = connection.prepareCall(hql2);
                statement2.setLong(1, auxnna.getIdnna());
                statement2.registerOutParameter(2, OracleTypes.CURSOR);
                statement2.execute();

                ResultSet rs2 = (ResultSet) statement2.getObject(2);
                while (rs2.next()) {
                    desig = new Designacion();
                    desig.setIddesignacion(rs2.getLong(1));
                    desig.setNDesignacion(rs2.getString(5));
                    desig.setPrioridad(rs2.getLong(6));
                    desig.setFechaPropuesta(rs2.getDate(7));
                    desig.setFechaConsejo(rs2.getDate(8));
                    desig.setAceptacionConsejo(rs2.getShort(9));
                    desig.setTipoPropuesta(rs2.getString(10));
                    desig.setObs(rs2.getString(11));
                    listDesig.add(desig);
                }
                auxnna.setDesignacions(listDesig);
                allNna.add(auxnna);
                statement2.close();
                rs2.close();
            }

            for (Nna auxnna : allNna) {
                if (auxnna.getClasificacion().equals("prioritario")) {
                    Set<EstudioCaso> listEst = new HashSet<EstudioCaso>();
                    String hql3 = "{call HN_GET_ESTUDIOS_CASO(?,?)}";
                    CallableStatement statement3 = connection.prepareCall(hql3);
                    statement3.setLong(1, auxnna.getIdnna());
                    statement3.registerOutParameter(2, OracleTypes.CURSOR);
                    statement3.execute();

                    ResultSet rs3 = (ResultSet) statement3.getObject(2);
                    while (rs3.next()) {
                        est = new EstudioCaso();
                        est.setIdestudioCaso(rs3.getLong(1));
                        est.setOrden(rs3.getString(4));
                        est.setFechaEstudio(rs3.getDate(5));
                        est.setFechaSolAdop(rs3.getDate(6));
                        est.setResultado(rs3.getString(7));
                        est.setPrioridad(rs3.getLong(8));
                        est.setNSolicitud(rs3.getLong(9));
                        listEst.add(est);
                    }
                    auxnna.setEstudioCasos(listEst);
                    statement3.close();
                    rs3.close();
                }
                allNnaFinal.add(auxnna);
            }

            //METODO BUBBLESORT PARA ORDENAR POR CODIGO
            if (clasif.equals("prioritario")) {
                Nna auxnna2;
                int n = allNnaFinal.size();
                for (int i = 0; i < n - 1; i++) {
                    for (int j = i; j < n - 1; j++) {
                        if (allNnaFinal.get(i).getExpedienteNnas().isEmpty()) {
                            if (!allNnaFinal.get(j + 1).getExpedienteNnas().isEmpty()) {
                                auxnna2 = allNnaFinal.get(i);
                                allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                allNnaFinal.set(j + 1, auxnna2);
                            } else {
                                String apellidoPrev = "";
                                String apellidoNext = "";
                                try {
                                    apellidoPrev = allNnaFinal.get(i).getApellidoP();
                                    if (apellidoPrev == null) {
                                        apellidoPrev = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoPrev = "";
                                }
                                try {
                                    apellidoNext = allNnaFinal.get(j + 1).getApellidoP();
                                    if (apellidoNext == null) {
                                        apellidoNext = "";
                                    }
                                } catch (Exception ex) {
                                    apellidoNext = "";
                                }

                                if (apellidoPrev.compareToIgnoreCase(apellidoNext) > 0) {
                                    auxnna2 = allNnaFinal.get(i);
                                    allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                    allNnaFinal.set(j + 1, auxnna2);
                                }
                            }
                        } else {
                            Set<ExpedienteNna> listExp1 = allNnaFinal.get(i).getExpedienteNnas();
                            Set<ExpedienteNna> listExp2 = allNnaFinal.get(j + 1).getExpedienteNnas();
                            if (!listExp2.isEmpty()) {
                                for (ExpedienteNna exp1 : listExp1) {
                                    for (ExpedienteNna exp2 : listExp2) {
                                        String codant = exp1.getCodigoReferencia();
                                        String codpost = exp2.getCodigoReferencia();
                                        if (codant == null) {
                                            codant = "";
                                        }
                                        if (codpost == null) {
                                            codpost = "";
                                        }
                                        if (codant.compareToIgnoreCase(codpost) > 0) {
                                            auxnna2 = allNnaFinal.get(i);
                                            allNnaFinal.set(i, allNnaFinal.get(j + 1));
                                            allNnaFinal.set(j + 1, auxnna2);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    };
    session.doWork(work);

    return allNnaFinal;
}

From source file:org.apache.phoenix.end2end.DateTimeIT.java

public void testDateFormatTimeZone(String timeZoneId) throws Exception {
    Properties props = new Properties();
    props.setProperty("phoenix.query.dateFormatTimeZone", timeZoneId);
    Connection conn1 = DriverManager.getConnection(getUrl(), props);

    String tableName = generateUniqueName();
    String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (k1 INTEGER PRIMARY KEY," + " v_date DATE,"
            + " v_time TIME," + " v_timestamp TIMESTAMP)";
    try {//  www  . j  av  a 2s  .c  o  m
        conn1.createStatement().execute(ddl);

        PhoenixConnection pConn = conn1.unwrap(PhoenixConnection.class);
        verifyTimeZoneIDWithConn(pConn, PDate.INSTANCE, timeZoneId);
        verifyTimeZoneIDWithConn(pConn, PTime.INSTANCE, timeZoneId);
        verifyTimeZoneIDWithConn(pConn, PTimestamp.INSTANCE, timeZoneId);

        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(timeZoneId));
        cal.setTime(date);
        String dateStr = DateUtil.getDateFormatter(DateUtil.DEFAULT_MS_DATE_FORMAT).format(date);

        String dml = "UPSERT INTO " + tableName + " VALUES (" + "1," + "'" + dateStr + "'," + "'" + dateStr
                + "'," + "'" + dateStr + "'" + ")";
        conn1.createStatement().execute(dml);
        conn1.commit();

        PhoenixStatement stmt = conn1.createStatement().unwrap(PhoenixStatement.class);
        ResultSet rs = stmt.executeQuery("SELECT v_date, v_time, v_timestamp FROM " + tableName);

        assertTrue(rs.next());
        assertEquals(rs.getDate(1).toString(), new Date(cal.getTimeInMillis()).toString());
        assertEquals(rs.getTime(2).toString(), new Time(cal.getTimeInMillis()).toString());
        assertEquals(rs.getTimestamp(3).getTime(), cal.getTimeInMillis());
        assertFalse(rs.next());

        StatementContext stmtContext = stmt.getQueryPlan().getContext();
        verifyTimeZoneIDWithFormatter(stmtContext.getDateFormatter(), timeZoneId);
        verifyTimeZoneIDWithFormatter(stmtContext.getTimeFormatter(), timeZoneId);
        verifyTimeZoneIDWithFormatter(stmtContext.getTimestampFormatter(), timeZoneId);

        stmt.close();
    } finally {
        conn1.close();
    }
}

From source file:dk.netarkivet.harvester.datamodel.DomainDBDAO.java

@Override
public HarvestInfo getDomainJobInfo(Job j, String domainName, String configName) {
    ArgumentNotValid.checkNotNull(j, "j");
    ArgumentNotValid.checkNotNullOrEmpty(domainName, "domainName");
    ArgumentNotValid.checkNotNullOrEmpty(configName, "configName");
    HarvestInfo resultInfo = null;/*from w  w w . j  av a2  s  .co  m*/

    Connection connection = HarvestDBConnection.get();
    PreparedStatement s = null;
    try {
        // Get domain_id for domainName
        long domainId = DBUtils.selectLongValue(connection, "SELECT domain_id FROM domains WHERE name=?",
                domainName);

        s = connection.prepareStatement(
                "SELECT stopreason, " + "objectcount, bytecount, " + "harvest_time FROM historyinfo WHERE "
                        + "job_id = ? AND " + "config_id = ? AND " + "harvest_id = ?");
        s.setLong(1, j.getJobID());
        s.setLong(2,
                DBUtils.selectLongValue(connection,
                        "SELECT config_id FROM configurations " + "WHERE name = ? AND domain_id=?", configName,
                        domainId));
        s.setLong(3, j.getOrigHarvestDefinitionID());
        ResultSet res = s.executeQuery();
        // If no result, the job may not have been run yet
        // return null HarvestInfo
        if (res.next()) {
            StopReason reason = StopReason.getStopReason(res.getInt(1));
            long objectCount = res.getLong(2);
            long byteCount = res.getLong(3);
            Date harvestTime = res.getDate(4);
            resultInfo = new HarvestInfo(j.getOrigHarvestDefinitionID(), j.getJobID(), domainName, configName,
                    harvestTime, byteCount, objectCount, reason);
        }

        return resultInfo;

    } catch (SQLException e) {
        throw new IOFailure("Failure getting DomainJobInfo" + "\n" + ExceptionUtils.getSQLExceptionCause(e), e);
    } finally {
        DBUtils.closeStatementIfOpen(s);
        HarvestDBConnection.release(connection);
    }
}

From source file:com.sjc.cc.login.service.impl.LoginServiceImpl.java

/**
 * //  w  w w .j  av  a  2  s.  co  m
 */
@Override
public TCcEmpskinconfig getSkinCfg(LoginUserInfo loginUserInfo) {
    TCcEmpskinconfig tCcEmpskinconfig = new TCcEmpskinconfig();
    StringBuffer sbBuffer = new StringBuffer();
    sbBuffer.append("       select t1.EMPSKIN_ID ,t1.SKIN_ID,t1.USER_PARTY_ID,t1.SKIN_DIR,");
    sbBuffer.append("      t1.SKIN_DESC,t1.ENABLE_FLG,t1.CRT_DATE,t1.UPT_DATE");
    sbBuffer.append("       from  T_CC_EMPSKINCONFIG t1  , T_CC_SKIN t2 ");
    sbBuffer.append("      where t1.SKIN_ID = t2.SKIN_ID and t2.ENABLE_FLG = 1 ");
    sbBuffer.append("       and t1.USER_PARTY_ID =  ");
    sbBuffer.append(loginUserInfo.getUserPartyId());
    List<TCcEmpskinconfig> skincfg = (List<TCcEmpskinconfig>) commonDao.querySqlByJdbcTpl(sbBuffer.toString(),
            null, new RowMapper() {
                @Override
                public Object mapRow(ResultSet rs, int arg1) throws SQLException {
                    TCcEmpskinconfig model = new TCcEmpskinconfig();
                    model.setEmpskinId(rs.getLong("EMPSKIN_ID"));
                    model.setSkinId(rs.getLong("SKIN_ID"));
                    model.setUserPartyId(rs.getLong("USER_PARTY_ID"));
                    model.setSkinDesc(rs.getString("SKIN_DESC"));
                    model.setSkinDir(rs.getString("SKIN_DIR"));
                    model.setCrtDate(rs.getDate("CRT_DATE"));
                    model.setUptDate(rs.getDate("UPT_DATE"));
                    return model;
                }
            });
    if (!skincfg.isEmpty()) {
        tCcEmpskinconfig = skincfg.get(0);
    }
    return tCcEmpskinconfig;
}

From source file:com.nridge.core.ds.rdbms.hsqldb.HDBSQLTable.java

private void addTableRowFromFunctionResultSet(DataTable aTable, ResultSet aResultSet) {
    DataField dataField;//from  w  w w . ja v a 2s .  com
    Logger appLogger = mAppMgr.getLogger(this, "addTableRowFromFunctionResultSet");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    FieldRow fieldRow = aTable.newRow();

    int columnNumber = 0;
    for (DataField pField : aTable.getColumnBag().getFields()) {
        columnNumber++;
        dataField = new DataField(pField);

        try {
            switch (pField.getType()) {
            case Integer:
                dataField.setValue(aResultSet.getInt(columnNumber));
                break;
            case Long:
                dataField.setValue(aResultSet.getLong(columnNumber));
                break;
            case Float:
                dataField.setValue(aResultSet.getFloat(columnNumber));
                break;
            case Double:
                dataField.setValue(aResultSet.getDouble(columnNumber));
                break;
            case Boolean:
                dataField.setValue(aResultSet.getBoolean(columnNumber));
                break;
            case Date:
                dataField.setValue(aResultSet.getDate(columnNumber));
                break;
            case Time:
                dataField.setValue(aResultSet.getTime(columnNumber));
                break;
            case DateTime:
                dataField.setValue(aResultSet.getTimestamp(columnNumber));
                break;
            default:
                dataField.setValue(aResultSet.getString(columnNumber));
                break;
            }

            if (!aResultSet.wasNull())
                aTable.setValueByName(fieldRow, pField.getName(), dataField.getValue());
        } catch (SQLException e) {
            appLogger.error(String.format("SQL Exception (%s): %s", pField.getName(), e.getMessage()));
        }
    }

    aTable.addRow(fieldRow);

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java

/**
 * Cette fonction permet de retourner les traductions d'un domaine
 *
 * @param ds//from  w ww  .j ava  2 s . c o  m
 * @param idGroup
 * @param idThesaurus
 * @return
 */
public ArrayList<NodeGroupTraductions> getAllGroupTraduction(HikariDataSource ds, String idGroup,
        String idThesaurus) {

    Connection conn;
    Statement stmt;
    ArrayList<NodeGroupTraductions> nodeGroupTraductionsList = null;

    try {
        // Get connection from pool
        conn = ds.getConnection();
        try {
            stmt = conn.createStatement();
            try {

                String query = "select lang, lexicalvalue, created, modified from concept_group_label "
                        + "where idgroup = '" + idGroup + "'" + " and idthesaurus = '" + idThesaurus + "'";

                ResultSet resultSet = stmt.executeQuery(query);
                if (resultSet != null) {
                    nodeGroupTraductionsList = new ArrayList<>();
                    while (resultSet.next()) {
                        NodeGroupTraductions nodeGroupTraductions = new NodeGroupTraductions();
                        // cas du Group non traduit
                        nodeGroupTraductions.setIdLang(resultSet.getString("lang"));
                        nodeGroupTraductions.setTitle(resultSet.getString("lexicalvalue"));
                        nodeGroupTraductions.setCreated(resultSet.getDate("created"));
                        nodeGroupTraductions.setModified(resultSet.getDate("modified"));
                        nodeGroupTraductionsList.add(nodeGroupTraductions);
                    }
                }

            } finally {
                stmt.close();
            }
        } finally {
            conn.close();
        }
    } catch (SQLException sqle) {
        // Log exception
        log.error("Error while getting All traduction of Group : " + idGroup, sqle);
    }
    return nodeGroupTraductionsList;
}

From source file:com.nridge.core.ds.rdbms.hsqldb.HDBSQLTable.java

private void addTableRowFromResultSet(DataTable aTable, ResultSet aResultSet) {
    String columnName;//w w w . j a  v  a2s  .c o  m
    DataField dataField;
    Logger appLogger = mAppMgr.getLogger(this, "addTableRowFromResultSet");

    appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER);

    FieldRow fieldRow = aTable.newRow();

    for (DataField pField : aTable.getColumnBag().getFields()) {
        dataField = new DataField(pField);

        try {
            columnName = columnName(pField.getName());

            switch (pField.getType()) {
            case Integer:
                dataField.setValue(aResultSet.getInt(columnName));
                break;
            case Long:
                dataField.setValue(aResultSet.getLong(columnName));
                break;
            case Float:
                dataField.setValue(aResultSet.getFloat(columnName));
                break;
            case Double:
                dataField.setValue(aResultSet.getDouble(columnName));
                break;
            case Boolean:
                dataField.setValue(aResultSet.getBoolean(columnName));
                break;
            case Date:
                dataField.setValue(aResultSet.getDate(columnName));
                break;
            case Time:
                dataField.setValue(aResultSet.getTime(columnName));
                break;
            case DateTime:
                dataField.setValue(aResultSet.getTimestamp(columnName));
                break;
            default:
                dataField.setValue(aResultSet.getString(columnName));
                break;
            }

            if (!aResultSet.wasNull())
                aTable.setValueByName(fieldRow, pField.getName(), dataField.getValue());
        } catch (SQLException e) {
            appLogger.error(String.format("SQL Exception (%s): %s", pField.getName(), e.getMessage()));
        } catch (NSException e) {
            appLogger.error(String.format("NS Exception (%s): %s", pField.getName(), e.getMessage()));
        }
    }

    aTable.addRow(fieldRow);

    appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART);
}

From source file:org.apache.phoenix.end2end.DateTimeIT.java

@Test
public void testNowFunction() throws Exception {
    String tableName = generateUniqueName();
    Date date = new Date(System.currentTimeMillis());
    String ddl = "CREATE TABLE IF NOT EXISTS " + tableName
            + " (k1 INTEGER NOT NULL, timestamps TIMESTAMP CONSTRAINT pk PRIMARY KEY (k1))";
    conn.createStatement().execute(ddl);
    String dml = "UPSERT INTO " + tableName + " VALUES (?, ?)";
    PreparedStatement stmt = conn.prepareStatement(dml);
    stmt.setInt(1, 1);//from  www.j av a2s .com
    stmt.setDate(2, new Date(date.getTime() - 500));
    stmt.execute();
    stmt.setInt(1, 2);
    stmt.setDate(2, new Date(date.getTime() + 600000));
    stmt.execute();
    conn.commit();

    ResultSet rs = conn.createStatement()
            .executeQuery("SELECT * from " + tableName + "  where now() > timestamps");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    assertEquals(new Date(date.getTime() - 500), rs.getDate(2));
    assertFalse(rs.next());
}