List of usage examples for java.sql Statement getResultSet
ResultSet getResultSet() throws SQLException;
ResultSet
object. From source file:mom.trd.opentheso.bdd.helper.CandidateHelper.java
/** * Cette fonction permet de savoir si le terme existe ou non * @param ds/*w w w . ja v a 2 s. c om*/ * @param idConcept * @param idThesaurus * @param idLang * @return Objet class NodeConceptTree */ public boolean isTraductionExistOfCandidat(HikariDataSource ds, String idConcept, String idThesaurus, String idLang) { Connection conn; Statement stmt; ResultSet resultSet; boolean existe = false; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select term_candidat.id_term from term_candidat, concept_term_candidat" + " where term_candidat.id_term = concept_term_candidat.id_term and" + " concept_term_candidat.id_concept = '" + idConcept + "'" + " and term_candidat.lang = '" + idLang + "'" + " and term_candidat.id_thesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { resultSet.next(); if (resultSet.getRow() == 0) { existe = false; } else { existe = true; } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while asking if Traduction of Candidat exist : " + idConcept, sqle); } return existe; }
From source file:mom.trd.opentheso.bdd.helper.CandidateHelper.java
/** * Permet de retourner une ArrayList de NodeUser par * thsaurus et Concept //from w w w . j a v a 2s. co m * c'est la liste des personnes qui ont dpos ce candidat * * @param ds le pool de connexion * @param idConcept * @param idThesaurus * @return Objet Class ArrayList NodeUSer */ public ArrayList<NodeUser> getListUsersOfCandidat(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<NodeUser> nodeUserList = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT users.username, users.id_user," + " proposition.modified" + " FROM proposition, users WHERE" + " proposition.id_user = users.id_user" + " and proposition.id_concept = '" + idConcept + "'" + " and proposition.id_thesaurus = '" + idThesaurus + "'" + " order By proposition.modified DESC;"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { nodeUserList = new ArrayList<>(); while (resultSet.next()) { NodeUser nodeUser = new NodeUser(); nodeUser.setId(resultSet.getInt("id_user")); nodeUser.setName(resultSet.getString("username")); nodeUserList.add(nodeUser); } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List of nodeUsersCandidat of ConceptCandidat : " + idConcept, sqle); } return nodeUserList; }
From source file:mom.trd.opentheso.bdd.helper.TermHelper.java
/** * Cette fonction permet de retourner l'id du terme d'aprs un concept * * @param ds/*from w ww .j a va2s . c o m*/ * @param idConcept * @param idThesaurus * @return idTermCandidat */ public String getIdTermOfConcept(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; String idTerm = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT id_term" + " FROM preferred_term" + " WHERE id_thesaurus = '" + idThesaurus + "'" + " and id_concept = '" + idConcept + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { idTerm = resultSet.getString("id_term"); } else { return null; } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting idTerm of idConcept : " + idConcept, sqle); } return idTerm; }
From source file:mom.trd.opentheso.bdd.helper.CandidateHelper.java
/** * Permet de retourner une ArrayList de NodeConceptCandidat par * thsaurus et par id_user c'est la liste des candidats en attente (status = a) * Si le Candidat n'est pas traduit dans la langue en cours, on rcupre * l'identifiant pour l'afficher la place * @param ds// www . j a va2 s.co m * @param idThesaurus * @param idLang * @param id_user * @return */ public ArrayList<NodeCandidatValue> getListMyCandidatsWait(HikariDataSource ds, String idThesaurus, String idLang, Integer id_user) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<NodeCandidatValue> nodeCandidatLists = null; ArrayList tabIdConcept = new ArrayList(); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select concept_candidat.id_concept from concept_candidat, proposition" + " where concept_candidat.id_concept = proposition.id_concept and" + " concept_candidat.id_thesaurus= proposition.id_thesaurus" + " and proposition.id_user =" + id_user + " and proposition.id_thesaurus ='" + idThesaurus + "' and concept_candidat.status='a'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); while (resultSet.next()) { tabIdConcept.add(resultSet.getString("id_concept")); } nodeCandidatLists = new ArrayList<>(); for (Object tabIdConcept1 : tabIdConcept) { NodeCandidatValue nodeCandidatValue; nodeCandidatValue = getThisCandidat(ds, tabIdConcept1.toString(), idThesaurus, idLang); if (nodeCandidatValue == null) return null; nodeCandidatValue.setEtat("a"); nodeCandidatValue.setNbProp(getNbPropCandidat(ds, idThesaurus, tabIdConcept1.toString())); nodeCandidatLists.add(nodeCandidatValue); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List Group or Domain of thesaurus : " + idThesaurus, sqle); } return nodeCandidatLists; }
From source file:mom.trd.opentheso.bdd.helper.TermHelper.java
/** * Cette fonction permet de savoir si le terme est un parfait doublon ou non * si oui, on retourne l'identifiant, sinon, on retourne null * * @param ds/*from www.java 2 s . c om*/ * @param title * @param idThesaurus * @param idLang * @return idTerm or null */ public String isTermEqualTo(HikariDataSource ds, String title, String idThesaurus, String idLang) { Connection conn; Statement stmt; ResultSet resultSet; String idTerm = null; title = new StringPlus().convertString(title); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_term from term where " + "lexical_value = '" + title + "'" + " and lang = '" + idLang + "'" + " and id_thesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { idTerm = resultSet.getString("id_term"); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while asking if Term exist : " + title, sqle); } return idTerm; }
From source file:org.ramadda.repository.database.DatabaseManager.java
/** * _more_/*from w w w .j a v a 2 s . c om*/ * * @param clause _more_ * @param tableName _more_ * @param column _more_ * * @return _more_ * * @throws Exception _more_ */ public boolean tableContains(Clause clause, String tableName, String column) throws Exception { Statement statement = select(column, tableName, clause); ResultSet results = statement.getResultSet(); boolean result = results.next(); closeAndReleaseConnection(statement); return result; }
From source file:org.ramadda.repository.database.DatabaseManager.java
/** * _more_/*from w ww . ja v a 2 s .com*/ * * @param table _more_ * @param clause _more_ * * @return _more_ * * @throws Exception _more_ */ public int getCount(String table, Clause clause) throws Exception { Statement statement = select("count(*)", table, clause); ResultSet results = statement.getResultSet(); int result; if (!results.next()) { result = 0; } else { result = results.getInt(1); } closeAndReleaseConnection(statement); return result; }
From source file:mom.trd.opentheso.bdd.helper.CandidateHelper.java
/** * Permet de retourner une ArrayList de NodeConceptCandidat par * thsaurus//from w ww. j a v a 2 s . c om * Si le Candidat n'est pas traduit dans la langue en cours, on rcupre * l'identifiant pour l'afficher la place * * @param ds le pool de connexion * @param idConcept * @param idThesaurus * @param idUser * @return Objet Class ArrayList NodeProposition */ public NodeProposition getNodePropositionOfUser(HikariDataSource ds, String idConcept, String idThesaurus, int idUser) { Connection conn; Statement stmt; ResultSet resultSet; NodeProposition nodeProposition = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT proposition.id_user," + " users.username, proposition.note," + " proposition.created," + " proposition.modified," + " proposition.concept_parent," + " proposition.id_group" + " FROM proposition, users WHERE " + " proposition.id_user = users.id_user" + " and proposition.id_concept = '" + idConcept + "'" + " and proposition.id_thesaurus = '" + idThesaurus + "'" + " and proposition.id_user = " + idUser; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { if (resultSet.next()) { nodeProposition = new NodeProposition(); nodeProposition.setId_user(resultSet.getInt("id_user")); nodeProposition.setUser(resultSet.getString("username")); nodeProposition.setNote(resultSet.getString("note")); nodeProposition.setCreated(resultSet.getDate("created")); nodeProposition.setModified(resultSet.getDate("modified")); nodeProposition.setIdConceptParent(resultSet.getString("concept_parent")); nodeProposition.setIdGroup(resultSet.getString("id_group")); } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List of node Proposition Candidats of Concept Candidat : " + idConcept, sqle); } return nodeProposition; }
From source file:mom.trd.opentheso.bdd.helper.TermHelper.java
/** * Cette fonction permet de savoir si le terme existe ou non * * @param ds// w w w .ja v a 2s .c om * @param title * @param idThesaurus * @param idLang * @return boolean */ public boolean isTermExist(HikariDataSource ds, String title, String idThesaurus, String idLang) { Connection conn; Statement stmt; ResultSet resultSet; boolean existe = false; title = new StringPlus().convertString(title); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_term from term where " + "unaccent_string(lexical_value) ilike " + "unaccent_string('" + title + "') and lang = '" + idLang + "' and id_thesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { existe = resultSet.getRow() != 0; } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while asking if Title of Term exist : " + title, sqle); } return existe; }
From source file:mom.trd.opentheso.bdd.helper.CandidateHelper.java
/** * Cette fonction permet de rcuprer un candidat * avec sa traduction, sinon, son identifiant * /*from www . j av a2 s .c o m*/ * @param ds * @param idCandidat * @param idThesaurus * @param idLang * @return Objet class NodeCandidatValue */ public NodeCandidatValue getThisCandidat(HikariDataSource ds, String idCandidat, String idThesaurus, String idLang) { Connection conn; Statement stmt; ResultSet resultSet; NodeCandidatValue nodeCandidatList = null; // if(isTraductionExistOfCandidat(ds, idConcept, idThesaurus, idLang)) { try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT term_candidat.lexical_value" + " FROM concept_term_candidat, term_candidat" + " WHERE concept_term_candidat.id_term = term_candidat.id_term" + " AND concept_term_candidat.id_concept = '" + idCandidat + "'" + " AND term_candidat.lang = '" + idLang + "'" + " AND term_candidat.id_thesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { nodeCandidatList = new NodeCandidatValue(); nodeCandidatList.setValue(resultSet.getString("lexical_value").trim()); nodeCandidatList.setIdConcept(idCandidat); } else { nodeCandidatList = new NodeCandidatValue(); nodeCandidatList.setValue(""); nodeCandidatList.setIdConcept(idCandidat); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting Concept : " + idCandidat, sqle); } /* } else { try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT concept_candidat.id_concept," + " concept_candidat.status FROM" + " concept_candidat" + " WHERE concept_candidat.id_concept ='" + idConcept +"'" + " and concept_candidat.id_thesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { while(resultSet.next()) { nodeCandidatList = new NodeCandidatValue(); nodeCandidatList.setValue(""); nodeCandidatList.setIdConcept(idConcept); nodeCandidatList.setEtat(resultSet.getString("status")); nodeCandidatList.setNbProp(getNbPropCandidat(ds,idThesaurus,idConcept)); } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting Concept : " + idConcept, sqle); } }*/ return nodeCandidatList; }