Refine search
throws ResourceException { if (!isActive) { throw new ResourceException( "JCAConnectionManagerImpl::allocateConnection::No valid Connection available"); } catch (PoolException ex) { throw new ResourceException( String.format( "JCAConnectionManagerImpl:: allocateConnection : in getting connection from pool due to %s", throw new ResourceException( String.format("JCAConnectionManagerImpl:: allocateConnection : in transaction due to %s", ex.getMessage()), ex); } catch (SystemException ex) { throw new ResourceException( String.format( "JCAConnectionManagerImpl:: allocateConnection :system exception due to %s",
/** * Destroys the underline physical connection to EIS. * * @param connectionObject connection Object. */ @Override void destroyPooledConnection(Object connectionObject) { try { ((ManagedConnection) connectionObject) .removeConnectionEventListener((ConnectionEventListener) connEventListner); ((ManagedConnection) connectionObject).destroy(); connectionObject = null; } catch (ResourceException rex) { if (logger.isTraceEnabled()) { logger.trace( "ManagedPoolcacheImpl::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is {}", rex.getMessage(), rex); } } } }
/** * Returns a detailed message string describing this exception. * * @return a detailed message string. */ public String getMessage() { String msg = super.getMessage(); String ec = getErrorCode(); if ((msg == null) && (ec == null)) { return null; } if ((msg != null) && (ec != null)) { return (msg + ", error code: " + ec); } return ((msg != null) ? msg : ("error code: " + ec)); } }
public void cleanup() throws ResourceException { super.cleanup(); Connection c = (Connection) physicalConnection; try { //TODO reset tx isolation level if (!c.getAutoCommit()) { c.setAutoCommit(true); } } catch (SQLException e) { throw new ResourceException("Could not reset autocommit when returning to pool", e); } }
public MetaDataImpl(ManagedConnectionImpl _mcon) throws ResourceException { dMetaData = null; try { mcon = _mcon; dMetaData = mcon.connection.getMetaData(); } catch (SQLException se) { throw new ResourceException(se.getMessage()); } }
public void commit() throws SQLException { ManagedConnectionHandle<Connection, ConnectionHandle> mc = getManagedConnection(); Connection c = mc.getPhysicalConnection(); if (c.getAutoCommit()) { return; } try { LocalTransaction tx = mc.getClientLocalTransaction(); tx.commit(); tx.begin(); } catch (ResourceException e) { if (e.getCause() instanceof SQLException) { throw (SQLException) e.getCause(); } else { throw (SQLException) new SQLException().initCause(e); } } }
/** Returns the JDBC Product version * * @return String Product version of the JDBC instance **/ public String getEISProductVersion() throws ResourceException { try { return(dMetaData.getDatabaseProductVersion()); } catch (SQLException se) { throw new ResourceException(se.getMessage()); } }
public Connection getConnection() throws SQLException { if (isDebugOn) { mcf.trace.log(BasicLevel.DEBUG, ""); } try { Connection con = (Connection) cm.allocateConnection(mcf, null); if (con == null) { SQLException se = new SQLException("Null connection object returned"); throw se; } return con; } catch (ResourceException re) { throw new SQLException(re.getMessage()); } }
public Connection getConnection() throws SQLException { try { return (Connection) cm.allocateConnection(mcf, containerRequestInfo); } catch (ResourceException e) { if (e.getCause() instanceof SQLException) { throw (SQLException) e.getCause(); } else { throw (SQLException) new SQLException().initCause(e); } } }
/** ******************************************************* */ public void begin() throws ResourceException { if (inLocalTransaction) throw new ResourceException("The managedConnection is already in a LocalTransaction"); try { inLocalTransaction = true; connection.setAutoCommit(false); } catch (Exception ex) { } }
private void throwResourceException(SQLException paramSQLException) throws ResourceException { ResourceException localResourceException = new ResourceException(ResourceBundle.getBundle("com/sun/connector/jaxr/LocalStrings").getString("SQLException:_") + paramSQLException.getMessage()); localResourceException.setLinkedException(paramSQLException); throw localResourceException; }
@Override public void commit() throws ResourceException { Connection conn = _driverConnection; if (conn == null) throw new ResourceException(L.l("connection is closed")); try { conn.commit(); } catch (SQLException e) { throw new ResourceException(e) ; } try { setAutoCommit(_oldAutoCommit); } catch (SQLException e) { throw new ResourceException(e) ; } }
import java.sql.SQLException; import javax.resource.ResourceException; public class Linking { public static void main(String[] args) { SQLException resW = new SQLException("blubb"); ResourceException resX = new ResourceException("a message", resW); SQLException sqlExc = null; Throwable linkedExc = resX.getCause(); // if linkedExc exception is a SQL Exception, assign it to sqlExc if (linkedExc instanceof SQLException) { sqlExc = (SQLException) linkedExc; } if (sqlExc != null) sqlExc.printStackTrace(); } }
@Override public void rollback() throws ResourceException { Connection conn = _driverConnection; if (conn == null) throw new ResourceException(L.l("connection is closed")); try { conn.rollback(); } catch (SQLException e) { throw new ResourceException(e) ; } try { setAutoCommit(_oldAutoCommit); } catch (SQLException e) { throw new ResourceException(e) ; } } }
@Override protected XAConnection getPhysicalConnection(CredentialExtractor credentialExtractor) throws ResourceException { XAConnection connection = super.getPhysicalConnection(credentialExtractor); int isolationLevel = dataSourceDescription.getIsolationLevel(); if (isolationLevel != -1) { try { connection.getConnection().setTransactionIsolation(isolationLevel); } catch (SQLException e) { throw new ResourceException("Error setting transaction isolation level for ", dataSourceDescription.getName()); } } return connection; } }
private String getDescriptor(String key) throws ResourceException { try { return mcf.getRepository().getDescriptor(key); } catch (RepositoryException e) { log("Failed to access the repository", e); ResourceException exception = new ResourceException( "Failed to access the repository: " + e.getMessage()); exception.initCause(e); throw exception; } }
@ControllerAdvice public class ExceptionHandlerAdvice { @ExceptionHandler(ResourceException.class) public ResponseEntity handleException(ResourceException e) { // log exception return ResponseEntity.status(e.getHttpStatus()).body(e.getMessage()); } }
/** * Creates a new connection for the managed connection pool. * * @return the managed connection from the EIS as ManagedConnection object. */ @Override public Object getNewPoolConnection() throws PoolException { ManagedConnection manConn = null; try { manConn = connFactory.createManagedConnection(sub, connReqInfo); } catch (ResourceException rex) { rex.printStackTrace(); throw new PoolException( "ManagedPoolCacheImpl::getNewConnection: Exception in creating new Managed PooledConnection", rex); } manConn .addConnectionEventListener((javax.resource.spi.ConnectionEventListener) connEventListner); return manConn; }
/** * <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); } }
/** * @deprecated */ public Exception getLinkedException() { return (Exception) getCause(); }