List of usage examples for java.sql Statement getResultSet
ResultSet getResultSet() throws SQLException;
ResultSet
object. From source file:Tim.Amusement.java
protected void getAypwipList() { Connection con;/*from w w w.j av a 2 s .c o m*/ try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `aypwips`"); ResultSet rs = s.getResultSet(); this.aypwips.clear(); while (rs.next()) { this.aypwips.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Tim.Amusement.java
protected void getColourList() { Connection con;// ww w . j a v a 2 s . co m try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `colours`"); ResultSet rs = s.getResultSet(); this.colours.clear(); while (rs.next()) { this.colours.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Tim.Amusement.java
protected void getDeityList() { Connection con;//from w ww . ja v a 2 s .c om try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `deities`"); ResultSet rs = s.getResultSet(); this.deities.clear(); while (rs.next()) { this.deities.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.java
/** * Verifies that the root file system entry exists. If it doesn't exist yet * it will be automatically created./*from w w w. j ava 2s.co m*/ * * @throws Exception if an error occurs */ protected void verifyRootExists() throws Exception { // check if root file system entry exists synchronized (selectFolderExistSQL) { ResultSet rs = null; try { Statement stmt = executeStmt(selectFolderExistSQL, new Object[] { FileSystem.SEPARATOR, "" }); rs = stmt.getResultSet(); if (rs.next()) { // root entry exists return; } } catch (SQLException e) { String msg = "failed to check existence of file system root entry"; log.error(msg, e); throw new FileSystemException(msg, e); } finally { closeResultSet(rs); } } // the root entry doesn't exist yet, create it... createDeepFolder(FileSystem.SEPARATOR); }
From source file:Tim.Amusement.java
protected void getFlavourList() { Connection con;// w w w . ja va 2s. c o m try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `flavours`"); ResultSet rs = s.getResultSet(); this.flavours.clear(); while (rs.next()) { this.flavours.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Tim.Amusement.java
protected void getEightballList() { Connection con;/*from w ww .java 2 s. c o m*/ try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `eightballs`"); ResultSet rs = s.getResultSet(); this.eightballs.clear(); while (rs.next()) { this.eightballs.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.java
/** * {@inheritDoc}// www. j a v a 2 s. c o m */ public String[] list(String folderPath) throws FileSystemException { if (!initialized) { throw new IllegalStateException("not initialized"); } FileSystemPathUtil.checkFormat(folderPath); if (!isFolder(folderPath)) { throw new FileSystemException("no such folder: " + folderPath); } synchronized (selectFileAndFolderNamesSQL) { ResultSet rs = null; try { Statement stmt = executeStmt(selectFileAndFolderNamesSQL, new Object[] { folderPath }); rs = stmt.getResultSet(); ArrayList names = new ArrayList(); while (rs.next()) { String name = rs.getString(1); if (name.length() == 0 && FileSystemPathUtil.denotesRoot(folderPath)) { // this is the file system root entry, skip... continue; } names.add(name); } return (String[]) names.toArray(new String[names.size()]); } catch (SQLException e) { String msg = "failed to list child entries of folder: " + folderPath; log.error(msg, e); throw new FileSystemException(msg, e); } finally { closeResultSet(rs); } } }
From source file:Tim.Amusement.java
protected void getCommandmentList() { Connection con;/* ww w. j a v a2s .c o m*/ try { con = Tim.db.pool.getConnection(timeout); Statement s = con.createStatement(); s.executeQuery("SELECT `string` FROM `commandments`"); ResultSet rs = s.getResultSet(); this.commandments.clear(); while (rs.next()) { this.commandments.add(rs.getString("string")); } con.close(); } catch (SQLException ex) { Logger.getLogger(Tim.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:mom.trd.opentheso.bdd.helper.ThesaurusHelper.java
/** * Permet de retourner un thsaurus par identifiant et par langue / ou null * si rien cette fonction ne retourne pas les dtails et les traductions * * @param ds le pool de connexion/*w w w .j a va2s .c o m*/ * @param idThesaurus * @param idLang * @return Objet Class Thesaurus */ public Thesaurus getThisThesaurus(HikariDataSource ds, String idThesaurus, String idLang) { idLang = idLang.trim(); Connection conn; Statement stmt; ResultSet resultSet; Thesaurus thesaurus = null; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { String query = "select * from thesaurus_label where id_thesaurus = '" + idThesaurus + "' and lang = '" + idLang + "'"; stmt.executeQuery(query); resultSet = stmt.getResultSet(); if (resultSet.next()) { if (resultSet.getString("lang") == null) { return null; } else { thesaurus = new Thesaurus(); thesaurus.setId_thesaurus(idThesaurus); thesaurus.setContributor(resultSet.getString("contributor")); thesaurus.setCoverage(resultSet.getString("coverage")); thesaurus.setCreator(resultSet.getString("creator")); thesaurus.setCreated(resultSet.getDate("created")); thesaurus.setModified(resultSet.getDate("modified")); thesaurus.setDescription(resultSet.getString("description")); thesaurus.setFormat(resultSet.getString("format")); thesaurus.setLanguage(resultSet.getString("lang")); thesaurus.setPublisher(resultSet.getString("publisher")); thesaurus.setRelation(resultSet.getString("relation")); thesaurus.setRights(resultSet.getString("rights")); thesaurus.setSource(resultSet.getString("source")); thesaurus.setSubject(resultSet.getString("subject")); thesaurus.setTitle(resultSet.getString("title")); thesaurus.setType(resultSet.getString("type")); } } resultSet.close(); } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while getting This Thesaurus : " + idThesaurus, sqle); } return thesaurus; }
From source file:org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.java
/** * {@inheritDoc}/*from w ww . j av a2 s .c om*/ */ public InputStream getInputStream(String filePath) throws FileSystemException { if (!initialized) { throw new IllegalStateException("not initialized"); } FileSystemPathUtil.checkFormat(filePath); String parentDir = FileSystemPathUtil.getParentDir(filePath); String name = FileSystemPathUtil.getName(filePath); synchronized (selectDataSQL) { try { Statement stmt = executeStmt(selectDataSQL, new Object[] { parentDir, name }); final ResultSet rs = stmt.getResultSet(); if (!rs.next()) { throw new FileSystemException("no such file: " + filePath); } InputStream in = rs.getBinaryStream(1); /** * return an InputStream wrapper in order to * close the ResultSet when the stream is closed */ return new FilterInputStream(in) { public void close() throws IOException { super.close(); // close ResultSet closeResultSet(rs); } }; } catch (SQLException e) { String msg = "failed to retrieve data of file: " + filePath; log.error(msg, e); throw new FileSystemException(msg, e); } } }