/** * @param ex * ResourceException * @return Non-null exception linked to FBResourceException, or the original * (FB)ResourceException. */ @SuppressWarnings("deprecation") private static Throwable resolveCause(ResourceException ex) { if (ex instanceof FBResourceException && ex.getLinkedException() != null) { return ex.getLinkedException(); } return ex; }
/** * @param ex * ResourceException * @return Non-null exception linked to FBResourceException, or the original * (FB)ResourceException. */ @SuppressWarnings("deprecation") private static Throwable resolveCause(ResourceException ex) { if (ex instanceof FBResourceException && ex.getLinkedException() != null) { return ex.getLinkedException(); } return ex; }
/** * Return the repository, automatically creating it if needed. */ @SuppressWarnings("deprecation") public Repository getRepository() throws RepositoryException { if (repository == null) { synchronized (this) { try { createRepository(); } catch (ResourceException e) { throw (RepositoryException) e.getLinkedException(); } } } return repository; }
/** * Return the repository, automatically creating it if needed. */ @SuppressWarnings("deprecation") public Repository getRepository() throws RepositoryException { if (repository == null) { synchronized (this) { try { createRepository(); } catch (ResourceException e) { throw (RepositoryException) e.getLinkedException(); } } } return repository; }
/** * <p>Attempt to establish a database connection. * * @return a Connection to the database * @throws SQLException * if a database-access error occurs. */ @SuppressWarnings("deprecation") public Connection getConnection() throws SQLException { try { return (Connection) cm.allocateConnection(mcf, mcf.getDefaultConnectionRequestInfo()); } catch (ResourceException re) { if (re.getCause() instanceof SQLException) { throw (SQLException) re.getCause(); } if (re.getLinkedException() instanceof SQLException) { throw (SQLException) re.getLinkedException(); } throw new FBSQLException(re); } }
/** * <p>Attempt to establish a database connection. * * @return a Connection to the database * @throws SQLException * if a database-access error occurs. */ @SuppressWarnings("deprecation") public Connection getConnection() throws SQLException { try { return (Connection) cm.allocateConnection(mcf, mcf.getDefaultConnectionRequestInfo()); } catch (ResourceException re) { if (re.getCause() instanceof SQLException) { throw (SQLException) re.getCause(); } if (re.getLinkedException() instanceof SQLException) { throw (SQLException) re.getLinkedException(); } throw new FBSQLException(re); } }
public ResourceHandle createResource() throws PoolingException { try { ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo); ResourceHandle resource = createResourceHandle(mc, spec, this, info); ConnectionEventListener l = new ConnectionListenerImpl(resource); mc.addConnectionEventListener(l); return resource; } catch (ResourceException ex) { Object[] params = new Object[]{spec.getPoolInfo(), ex.toString()}; _logger.log(Level.WARNING,"poolmgr.create_resource_error",params); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE,"Resource Exception while creating resource",ex); } if (ex.getLinkedException() != null) { _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex .getLinkedException().toString()); } throw new PoolingException(ex); } }
public ResourceHandle createResource() throws PoolingException { try { ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo); ResourceHandle resource = createResourceHandle(mc, spec, this, info); ConnectionEventListener l = new ConnectionListenerImpl(resource); mc.addConnectionEventListener(l); return resource; } catch (ResourceException ex) { Object[] params = new Object[]{spec.getPoolInfo(), ex.toString()}; _logger.log(Level.WARNING,"poolmgr.create_resource_error",params); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE,"Resource Exception while creating resource",ex); } if (ex.getLinkedException() != null) { _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex .getLinkedException().toString()); } throw new PoolingException(ex); } }
public ResourceHandle createResource() throws PoolingException { try { ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo); ResourceHandle resource = createResourceHandle(mc, spec, this, info); ConnectionEventListener l = new LocalTxConnectionEventListener(resource); mc.addConnectionEventListener(l); resource.setListener(l); XAResource xares = new ConnectorXAResource(resource, spec, this, info); resource.fillInResourceObjects(null, xares); return resource; } catch (ResourceException ex) { Object[] params = new Object[]{spec.getPoolInfo(), ex.toString()}; _logger.log(Level.WARNING, "poolmgr.create_resource_error", params); if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Resource Exception while creating resource", ex); } if (ex.getLinkedException() != null) { _logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex .getLinkedException().toString()); } throw new PoolingException(ex); } }
/** * <p>Attempt to establish a database connection. * * @param username * the database user on whose behalf the Connection is * being made * @param password * the user's password * @return a Connection to the database * @throws SQLException * if a database-access error occurs. */ @SuppressWarnings("deprecation") public Connection getConnection(String username, String password) throws SQLException { try { //mcf makes a copy for us. FBConnectionRequestInfo subjectCri = mcf.getDefaultConnectionRequestInfo(); subjectCri.setUserName(username); subjectCri.setPassword(password); return (Connection) cm.allocateConnection(mcf, subjectCri); } catch (ResourceException re) { if (re.getCause() instanceof SQLException) { throw (SQLException) re.getCause(); } if (re.getLinkedException() instanceof SQLException) { throw (SQLException) re.getLinkedException(); } throw new FBSQLException(re); } }
/** * <p>Attempt to establish a database connection. * * @param username * the database user on whose behalf the Connection is * being made * @param password * the user's password * @return a Connection to the database * @throws SQLException * if a database-access error occurs. */ @SuppressWarnings("deprecation") public Connection getConnection(String username, String password) throws SQLException { try { //mcf makes a copy for us. FBConnectionRequestInfo subjectCri = mcf.getDefaultConnectionRequestInfo(); subjectCri.setUserName(username); subjectCri.setPassword(password); return (Connection) cm.allocateConnection(mcf, subjectCri); } catch (ResourceException re) { if (re.getCause() instanceof SQLException) { throw (SQLException) re.getCause(); } if (re.getLinkedException() instanceof SQLException) { throw (SQLException) re.getLinkedException(); } throw new FBSQLException(re); } }
log.warn("Linked exception:", re.getLinkedException());
public void testExceptionType() throws Exception { Exception nested = new Exception(); ResourceException setExc = new ResourceException(nested); GenericFailureInteraction interaction = new GenericFailureInteraction(true, setExc); interactionHandler.addImplementor(interaction); try { interactionHandler.execute(null, null, null); fail(); } catch(ResourceException exc) { assertSame(setExc, exc); assertSame(nested, exc.getLinkedException()); } } }
@SuppressWarnings( "deprecation" ) @Override public Session login( Credentials c, String workspace ) throws LoginException, NoSuchWorkspaceException, RepositoryException { try { return (Session)cm.allocateConnection(mcf, new JcrConnectionRequestInfo(c, workspace)); } catch (ResourceException e) { Throwable cause = e.getCause(); if (cause == null) { cause = e.getLinkedException(); } if (cause instanceof LoginException) { throw (LoginException)cause; } else if (cause instanceof NoSuchWorkspaceException) { throw (NoSuchWorkspaceException)cause; } else if (cause instanceof RepositoryException) { throw (RepositoryException)cause; } else if (cause != null) { throw new RepositoryException(cause); } else { throw new RepositoryException(e); } } }
/** * Creates a new session. */ @SuppressWarnings("deprecation") public Session login(Credentials creds, String workspace) throws RepositoryException { try { return (Session) cm.allocateConnection( mcf, new JCAConnectionRequestInfo(creds, workspace)); } catch (ResourceException e) { Throwable cause = e.getCause(); if (cause == null) { cause = e.getLinkedException(); } if (cause instanceof LoginException) { throw (LoginException) cause; } else if (cause instanceof NoSuchWorkspaceException) { throw (NoSuchWorkspaceException) cause; } else if (cause instanceof RepositoryException) { throw (RepositoryException) cause; } else if (cause != null) { throw new RepositoryException(cause); } else { throw new RepositoryException(e); } } }
/** * Creates a new session. */ @SuppressWarnings("deprecation") public Session login(Credentials creds, String workspace) throws RepositoryException { try { return (Session) cm.allocateConnection( mcf, new JCAConnectionRequestInfo(creds, workspace)); } catch (ResourceException e) { Throwable cause = e.getCause(); if (cause == null) { cause = e.getLinkedException(); } if (cause instanceof LoginException) { throw (LoginException) cause; } else if (cause instanceof NoSuchWorkspaceException) { throw (NoSuchWorkspaceException) cause; } else if (cause instanceof RepositoryException) { throw (RepositoryException) cause; } else if (cause != null) { throw new RepositoryException(cause); } else { throw new RepositoryException(e); } } }