private String getSynonymOwner(String synonymName) { PreparedStatement ps = null; ResultSet rs = null; String ret = null; try { ps = getConnection() .prepareStatement( "select table_owner from sys.all_synonyms where table_name=? and owner=?"); ps.setString(1, synonymName); ps.setString(2, getSchema()); rs = ps.executeQuery(); if (rs.next()) { ret = rs.getString(1); } else { String databaseStructure = getDatabaseStructureInfo(); throw new RuntimeException( "Wow! Synonym " + synonymName + " not found. How can it happen? " + databaseStructure); } } catch (SQLException e) { String databaseStructure = getDatabaseStructureInfo(); GLogger.error(e.getMessage(), e); throw new RuntimeException("Exception in getting synonym owner " + databaseStructure); } finally { dbHelper.close(rs, ps); } return ret; }
public String queryForString(String sql) { Statement s = null; ResultSet rs = null; try { s = getConnection().createStatement(); rs = s.executeQuery(sql); if (rs.next()) { return rs.getString(1); } return null; } catch (SQLException e) { e.printStackTrace(); return null; } finally { close(rs, null, s); } }