List of usage examples for java.sql Statement getResultSet
ResultSet getResultSet() throws SQLException;
ResultSet
object. From source file:mom.trd.opentheso.bdd.helper.RelationsHelper.java
/** * Cette fonction permet de rcuprer la liste des Id des termes * gnriques d'un concept// www. j a va 2 s . c om * * @param ds * @param idConcept * @param idThesaurus * @return Objet class Concept */ public ArrayList<String> getListIdBT(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<String> listIdBT = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_concept2 from hierarchical_relationship" + " where id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role = '" + "BT" + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { listIdBT = new ArrayList<>(); while (resultSet.next()) { listIdBT.add(resultSet.getString("id_concept2")); } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting Liste ID of BT Concept : " + idConcept, sqle); } return listIdBT; }
From source file:migration.ProjektMigration.java
/** * Creates the journalkosten.//from ww w .j a va2 s. co m */ public void createJournalkosten() { String load_sql; Statement load_stmt; ResultSet load_rs; String store_sql; PreparedStatement store_prepstmt; final ResultSet store_rs; try { load_sql = "SELECT IMwStO, IMwStP, IMwStPO, IPreisO, IPreisP, IPreisPO, IWaehrungO, IWaehrungP, IWaehrungPO, OPreisO, OPreisP, OPreisPO, Impact, ImpactDatum, MwStO, MwStP, MwStPO, WaehrungO, WaehrungP, WaehrungPO, Titelnummer FROM ZSTiteltabelle"; load_stmt = this.leg_con.createStatement(); store_sql = "INSERT INTO Journalkosten (IMwStO, IMwStP, IMwStPO, IPreisO, IPreisP, IPreisPO, IWaehrungO, IWaehrungP, IWaehrungPO, OPreisO, OPreisP, OPreisPO, impact, impactDatum, mwStO, mwStP, mwStPO, waehrungO, waehrungP, waehrungPO, journal_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; store_prepstmt = this.tgt_con.prepareStatement(store_sql); // evtl. // brauchen // wir // was // in // Richtung: // Statement.RETURN_GENERATED_KEYS // logger.info("Lese von ZSTiteltabelle (Journalkosten)"); load_stmt.execute(load_sql); load_rs = load_stmt.getResultSet(); // logger.info("Schreibe nach Journalkosten"); while (load_rs.next()) { final int titelnummer = load_rs.getInt("Titelnummer"); final int journalID = this.help.getIdFromIntArray(this.help.getJournals(), titelnummer); // ystem.out.println("Titelnummer: " + titelnummer + // " JournalID " + journalID); if ((titelnummer > 0) && (journalID > 0)) { store_prepstmt.setString(1, load_rs.getString("IMwStO")); store_prepstmt.setString(2, load_rs.getString("IMwStP")); store_prepstmt.setString(3, load_rs.getString("IMwStPO")); store_prepstmt.setFloat(4, load_rs.getFloat("IPreisO")); store_prepstmt.setFloat(5, load_rs.getFloat("IPreisP")); store_prepstmt.setFloat(6, load_rs.getFloat("IPreisPO")); store_prepstmt.setString(7, load_rs.getString("IWaehrungO")); store_prepstmt.setString(8, load_rs.getString("IWaehrungP")); store_prepstmt.setString(9, load_rs.getString("IWaehrungPO")); store_prepstmt.setFloat(10, load_rs.getFloat("OPreisO")); store_prepstmt.setFloat(11, load_rs.getFloat("OPreisP")); store_prepstmt.setFloat(12, load_rs.getFloat("OPreisPO")); store_prepstmt.setFloat(13, load_rs.getFloat("Impact")); store_prepstmt.setDate(14, load_rs.getDate("ImpactDatum")); store_prepstmt.setString(15, load_rs.getString("MwStO")); store_prepstmt.setString(16, load_rs.getString("MwStP")); store_prepstmt.setString(17, load_rs.getString("MwStPO")); store_prepstmt.setString(18, load_rs.getString("WaehrungO")); store_prepstmt.setString(19, load_rs.getString("WaehrungP")); store_prepstmt.setString(20, load_rs.getString("WaehrungPO")); store_prepstmt.setLong(21, journalID); store_prepstmt.executeUpdate(); } } } catch (final SQLException e) { e.printStackTrace(); // To change body of catch statement use File | // Settings | File Templates. } }
From source file:org.talend.dq.indicators.AbstractSchemaEvaluator.java
/** * DOC scorreia Comment method "getRowCounts". * //w w w .j a v a2 s. c o m * @param schemaIndic * @param quCatalog * @param quSchema * @param quTable * @return * @throws SQLException */ private long getRowCounts(String quCatalog, String quSchema, String quTable) throws SQLException { String sql = SELECT_COUNT_FROM + dbms().toQualifiedName(quCatalog, quSchema, quTable); long totalRowCount = 0; java.sql.Connection conn = getConnection(); if (conn == null || conn.isClosed()) { return totalRowCount; } Statement statement = null; // MOD qiongli 2012-8-13.TDQ-5907 if (DbmsLanguageFactory.isHive(dbmsLanguage.getDbmsName())) { statement = conn.createStatement(); } else { statement = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); } // not needed here statement.setFetchSize(fetchSize); try { if (log.isInfoEnabled()) { log.info("The execute query is: " + sql); //$NON-NLS-1$ } // MOD xqliu 2009-02-09 bug 6237 if (continueRun()) { statement.execute(sql); } } catch (SQLException e) { statement.close(); log.warn(e.getMessage() + " for the query: " + sql); //$NON-NLS-1$ if (log.isDebugEnabled()) { log.debug(e, e); } // some tables on Oracle give the following exception: // ORA-25191: cannot reference overflow table of an index-organized table reloadConnectionAfterException(quCatalog); return totalRowCount; } // get the results ResultSet resultSet = statement.getResultSet(); if (resultSet == null) { String mess = Messages.getString("Evaluator.NoResultSet", sql); //$NON-NLS-1$ log.warn(mess); } else { while (resultSet != null && resultSet.next()) { // MOD xqliu 2009-02-09 bug 6237 if (!continueRun()) { break; } // --- get content of column String str = String.valueOf(resultSet.getObject(1)); // MOD gdbu 2011-4-21 bug : 18975 Long count = IndicatorHelper.getLongFromObject(str); // ~18975 totalRowCount += count; if (log.isDebugEnabled()) { log.debug(quCatalog + "/" + quSchema + "/" + quTable + ": " + count); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } // TODO scorreia give a full row to indicator (indicator will have to handle its data?? } // --- release resultset resultSet.close(); } // -- release JDBC resources statement.close(); return totalRowCount; }
From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java
/** * Permet de retourner une ArrayList de String (idGroup) par thsaurus / ou * null si rien/* w w w . java 2 s. co m*/ * * @param ds le pool de connexion * @param idThesaurus * @return Objet Class ArrayList NodeConceptGroup */ public ArrayList<String> getListIdOfGroup(HikariDataSource ds, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList tabIdConceptGroup = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select idgroup from concept_group where idthesaurus = '" + idThesaurus + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); tabIdConceptGroup = new ArrayList(); while (resultSet.next()) { tabIdConceptGroup.add(resultSet.getString("idgroup")); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List Id or Groups of thesaurus : " + idThesaurus, sqle); } return tabIdConceptGroup; }
From source file:mom.trd.opentheso.bdd.helper.RelationsHelper.java
/** * Cette fonction permet de rcuprer la liste des Ids des termes * gnriques d'un concept//from w w w .ja va 2s.c o m * * @param ds * @param idConcept * @param idThesaurus * @return Objet class Concept */ public ArrayList<String> getListIdOfBT(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<String> listIdOfBt = new ArrayList<>(); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_concept2 from hierarchical_relationship" + " where id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role = '" + "BT" + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); while (resultSet.next()) { listIdOfBt.add(resultSet.getString("id_concept2")); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List Ids of BT of Concept : " + idConcept, sqle); } return listIdOfBt; }
From source file:mom.trd.opentheso.bdd.helper.RelationsHelper.java
/** * Cette fonction permet de rcuprer la liste des Ids des termes * associs d'un concept/* w w w . j a va 2s. c o m*/ * * @param ds * @param idConcept * @param idThesaurus * @return Objet class Concept */ public ArrayList<String> getListIdsOfRT(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<String> listIdsOfRT = new ArrayList<>(); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_concept2 from hierarchical_relationship" + " where id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role = '" + "RT" + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); while (resultSet.next()) { listIdsOfRT.add(resultSet.getString("id_concept2")); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting list Ids of RT of Concept : " + idConcept, sqle); } return listIdsOfRT; }
From source file:mom.trd.opentheso.bdd.helper.RelationsHelper.java
/** * Cette fonction permet de rcuprer la liste des Ids des termes * spcifiques d'un concept Utilise pour l'export des Concepts * * @param ds//from w w w. j a v a2 s .c o m * @param idConcept * @param idThesaurus * @return Objet class Array String */ public ArrayList<String> getListIdsOfNT(HikariDataSource ds, String idConcept, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<String> nodeListIdsNT = new ArrayList<>(); try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_concept2 from hierarchical_relationship" + " where id_thesaurus = '" + idThesaurus + "'" + " and id_concept1 = '" + idConcept + "'" + " and role = '" + "NT" + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); while (resultSet.next()) { nodeListIdsNT.add(resultSet.getString("id_concept2")); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List Ids of NT of Concept : " + idConcept, sqle); } return nodeListIdsNT; }
From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java
/** * Cette fonction permet de rcuprer l'identifiant Ark sinon renvoie un une * chaine vide/*from www . j a va 2 s. co m*/ * * @param ds * @param idGroup * @param idThesaurus * @return Objet class Concept */ public String getIdArkOfGroup(HikariDataSource ds, String idGroup, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; String ark = ""; try { conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select id_ark from concept_group where" + " idthesaurus = '" + idThesaurus + "'" + " and idgroup = '" + idGroup + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { ark = resultSet.getString("id_ark"); } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting idArk of Group : " + idGroup, sqle); } return ark; }
From source file:mom.trd.opentheso.bdd.helper.ThesaurusHelper.java
/** * Retourne la liste des traductions d'un thesaurus sous forme de ArrayList * d'Objet Languages_iso639//from w ww . ja va 2s.co m * * @param ds * @param idThesaurus * @return */ public ArrayList<Languages_iso639> getLanguagesOfThesaurus(HikariDataSource ds, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; ArrayList<Languages_iso639> lang = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT DISTINCT" + " languages_iso639.iso639_1, " + " languages_iso639.iso639_2, " + " languages_iso639.english_name, " + " languages_iso639.french_name, " + " thesaurus_label.lang" + " FROM " + " thesaurus_label," + " languages_iso639" + " WHERE" + " thesaurus_label.lang = languages_iso639.iso639_1 AND" + " thesaurus_label.lang = languages_iso639.iso639_1;"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet != null) { lang = new ArrayList<>(); while (resultSet.next()) { Languages_iso639 languages_iso639 = new Languages_iso639(); languages_iso639.setId_iso639_1(resultSet.getString("iso639_1")); languages_iso639.setId_iso639_2(resultSet.getString("iso639_2")); languages_iso639.setFrench_name(resultSet.getString("french_name")); languages_iso639.setFrench_name(resultSet.getString("english_name")); lang.add(languages_iso639); } } } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting List Language of thesaurus : " + idThesaurus, sqle); } return lang; }
From source file:mom.trd.opentheso.bdd.helper.GroupHelper.java
/** * Cette fonction permet de savoir si le Group est vide (pas de concepts) * * @param ds/*from w w w . j ava 2 s .co m*/ * @param idGroup * @param idThesaurus * @return */ public boolean isEmptyDomain(HikariDataSource ds, String idGroup, String idThesaurus) { Connection conn; Statement stmt; ResultSet resultSet; boolean group = false; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "SELECT id_concept FROM concept" + " WHERE id_thesaurus='" + idThesaurus + "'" + " AND id_group='" + idGroup + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); resultSet.next(); group = (resultSet.getRow() == 0); } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while testing if Group have Concept : " + idGroup, sqle); } return group; }