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" ); } }
OlapException createException(String msg) { return new OlapException(msg); }
/** * Converts a SQLException to an OlapException. Casts the exception * if it is already an OlapException, wraps otherwise. * * <p>This method is typically used as an adapter for SQLException * instances coming from a base class, where derived interface declares * that it throws the more specific OlapException. * * @param e Exception * @return Exception as an OlapException */ public OlapException toOlapException(SQLException e) { if (e instanceof OlapException) { return (OlapException) e; } else { return new OlapException(null, e); } } }
/** * Creates an exception in the context of a particular Cell. * * @param context Cell context for exception * @param msg Message * @return New exception */ OlapException createException(Cell context, String msg) { OlapException exception = new OlapException(msg); exception.setContext(context); return exception; }
public Object getOrderKey(Member m) throws OlapException { try { return ((MondrianOlap4jMember)m) .unwrap(RolapMemberBase.class).getOrderKey(); } catch (SQLException e) { throw new OlapException(e); } }
public Object getMemberKey(Member m) throws OlapException { try { return ((MondrianOlap4jMember)m) .unwrap(RolapMemberBase.class).getKey(); } catch (SQLException e) { throw new OlapException(e); } }
/** * Creates an exception with a given cause. * * @param msg Message * @param cause Causing exception * @return New exception */ OlapException createException( String msg, Throwable cause) { String sqlState = deduceSqlState(cause); assert !mondrian.util.Bug.olap4jUpgrade( "use OlapException(String, String, Throwable) ctor"); final OlapException e = new OlapException(msg, sqlState); e.initCause(cause); return e; }
MondrianOlap4jDriver.class.getName(), true); } catch (ClassNotFoundException e) { throw new OlapException("Cannot find mondrian olap4j driver.");
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); } }
if (databaseName == null) { if (serverInfo.datasourceMap.size() == 0) { throw new OlapException( "No databases configured on this server"); throw new OlapException( "No catalogs in the database named " + datasourceInfo.name);
rowCountSlot); if (resultSet == null) { throw new OlapException( "Cannot do DrillThrough operation on the cell");