public void close() throws KettleDatabaseException { try { if ( result != null ) { result.close(); } if ( olapConnection != null ) { olapConnection.close(); } } catch ( Exception e ) { throw new KettleDatabaseException( "Error closing connection" ); } }
public void openQuery() throws Exception { Class.forName( olap4jDriver ); OlapConnection connection = null; if ( Utils.isEmpty( username ) && Utils.isEmpty( password ) ) { connection = (OlapConnection) DriverManager.getConnection( olap4jUrl ); } else { connection = (OlapConnection) DriverManager.getConnection( olap4jUrl, username, password ); } OlapWrapper wrapper = connection; olapConnection = wrapper.unwrap( OlapConnection.class ); try { if ( !Utils.isEmpty( catalogName ) ) { olapConnection.setCatalog( catalogName ); } } catch ( SQLException e ) { throw new OlapException( "Error setting catalog for MDX statement: '" + catalogName + "'" ); } OlapStatement stmt = olapConnection.createStatement(); if ( !Utils.isEmpty( mdx ) ) { CellSet tmp = stmt.executeOlapQuery( mdx ); result = tmp; } else { throw new Exception( "Error executing empty MDX query" ); } }
connection = getConnection(request, Collections.<String, String>emptyMap()); statement = connection.createStatement(); resultSet = getExtra(connection).executeDrillthrough( connection.close(); } catch (SQLException e) {
/** * Executes a query and processes the result using a callback. * * @param queryString MDX query text */ public <T> T runQuery(String queryString, Util.Functor1<T, CellSet> f) { long start = System.currentTimeMillis(); OlapConnection connection = null; OlapStatement statement = null; CellSet cellSet = null; try { connection = getOlapConnection(); statement = connection.createStatement(); debug("CmdRunner.runQuery: AFTER createStatement"); start = System.currentTimeMillis(); cellSet = statement.executeOlapQuery(queryString); return f.apply(cellSet); } catch (SQLException e) { throw new RuntimeException(e); } finally { queryTime = (System.currentTimeMillis() - start); totalQueryTime += queryTime; debug("CmdRunner.runQuery: BOTTOM"); Util.close(cellSet, statement, connection); } }
/** * @see org.pivot4j.datasource.OlapConnectionFactory#destroyObject(org * .olap4j.OlapConnection) */ @Override public void destroyObject(OlapConnection con) { if (logger.isDebugEnabled()) { logger.debug("Closing a returned connection object : {}", con); } try { con.unwrap(OlapConnection.class).close(); } catch (SQLException e) { throw new PivotException(e); } } }
connection = dataSource.getConnection(); for (Cube cube : connection.getOlapSchema().getCubes()) { if (cube.isVisible()) { cubes.add(new CubeInfo(cube.getName(), cube.getCaption(), if (connection != null) { try { connection.close(); } catch (SQLException e) { throw new PivotException(e);
olapConnection.setCatalog(catalog); olapConnection.setSchema(schema); olapConnection.setRoleName(roleName);
getExtra(connection).setPreferList(connection); try { statement = connection.prepareOlapStatement(mdx); } catch (XmlaException ex) { throw ex; connection.close(); } catch (SQLException e) {
/** * @param dataSource * @return * @throws SQLException */ protected OlapConnection createConnection(OlapDataSource dataSource) throws SQLException { OlapConnection con = dataSource.getConnection(); if (roleName != null) { con.setRoleName(roleName); } if (locale != null) { con.setLocale(locale); } return con; }
public static XmlaExtra getExtra(OlapConnection connection) { try { final XmlaExtra extra = connection.unwrap(XmlaExtra.class); if (extra != null) { return extra;
Locale locale = XmlaUtil.convertToLocale( localeIdentifier ); if (locale != null) { connection.setLocale(locale);
public List<UISelectItem> getCubes() throws SQLException { if (cubeItems == null) { FacesContext context = FacesContext.getCurrentInstance(); ResourceBundle bundle = context.getApplication().getResourceBundle( context, "msg"); String defaultLabel = bundle.getString("message.cubeList.default"); this.cubeItems = new ArrayList<UISelectItem>(); UISelectItem defaultItem = new UISelectItem(); defaultItem.setItemLabel(defaultLabel); defaultItem.setItemValue(""); cubeItems.add(defaultItem); if (model != null) { OlapDataSource dataSource = ((PivotModelImpl) model) .getDataSource(); Schema schema = dataSource.getConnection().getOlapSchema(); List<Cube> cubes = schema.getCubes(); for (Cube cube : cubes) { if (cube.isVisible()) { UISelectItem item = new UISelectItem(); item.setItemLabel(cube.getCaption()); item.setItemValue(cube.getName()); cubeItems.add(item); } } } } return cubeItems; }
/** * @param roleName * the roleName to set * @see org.pivot4j.PivotModel#setRoleName(java.lang.String) */ public void setRoleName(String roleName) { this.roleName = roleName; if (connection != null) { try { connection.setRoleName(roleName); } catch (OlapException e) { throw new PivotException(e); } } }
/** * @param connection * @param mdx * @return * @throws OlapException */ protected CellSet executeMdx(OlapConnection connection, String mdx) throws OlapException { if (logger.isDebugEnabled()) { logger.debug(mdx); } Date start = new Date(System.currentTimeMillis()); OlapStatement stmt = connection.createStatement(); CellSet result = stmt.executeOlapQuery(mdx); long duration = System.currentTimeMillis() - start.getTime(); if (logger.isInfoEnabled()) { logger.info(String.format("Query execution time : %d ms", duration)); } fireQueryExecuted(start, duration, mdx); return result; }
public void flushSchemaCache(OlapConnection conn) throws OlapException { try { RolapConnection rConn = conn.unwrap(RolapConnection.class); rConn.getCacheControl(null).flushSchema( rConn.getSchema()); } catch (SQLException e) { throw new OlapException(e); } }
/** * Sets the current locale. * * @param locale * The locale to set * @see org.pivot4j.PivotModel#setLocale(java.util.Locale) */ public void setLocale(Locale locale) { this.locale = locale; if (connection != null) { connection.setLocale(locale); } }
String cubeName = queryAdapter.getCubeName(); Schema schema = connection.getOlapSchema(); cube = schema.getCubes().get(cubeName);
public void close() throws SQLException { cellSet.getStatement().getConnection().close(); }
@Override public void execute() throws TranslatorException { try { stmt = this.connection.createStatement(); cellSet = stmt.executeOlapQuery(mdxQuery); CellSetAxis rowAxis = this.cellSet.getAxes().get(Axis.ROWS.axisOrdinal()); rowPositionIterator = rowAxis.iterator(); columnsAxis = cellSet.getAxes().get(Axis.COLUMNS.axisOrdinal()); colWidth = rowAxis.getAxisMetaData().getHierarchies().size() + this.columnsAxis.getPositions().size(); } catch (SQLException e) { throw new TranslatorException(e); } }
if (connection != null && ourConnection) { try { connection.close(); } catch (SQLException e) {