public static XAConnection createXAConnection(Connection physicalConn) throws SQLException { return new PGXAConnection((BaseConnection) physicalConn); }
private Object loadXADataSource(Reference ref) { PGXADataSource ds = new PGXADataSource(); return loadBaseDataSource(ds, ref); } }
/** * Gets a connection to the PostgreSQL database. The database is identified by the DataSource * properties serverName, databaseName, and portNumber. The user to connect as is identified by * the DataSource properties user and password. * * @return A valid database connection. * @throws SQLException Occurs when the database connection cannot be established. */ public XAConnection getXAConnection() throws SQLException { return getXAConnection(getUser(), getPassword()); }
@Override public void commit(Xid xid, boolean onePhase) throws XAException { if (LOGGER.isLoggable(Level.FINEST)) { debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); } if (xid == null) { throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); } if (onePhase) { commitOnePhase(xid); } else { commitPrepared(xid); } }
public XADataSource createXADataSource(Properties props) throws SQLException { props = new SingleUseProperties(props); PGXADataSource dataSource = new PGXADataSource(); configureBaseDataSource(dataSource, props); return dataSource; } }
PGXAException(String message, Throwable cause, int errorCode) { super(message); initCause(cause); this.errorCode = errorCode; }
/** * This is for debugging purposes only. */ public String toString() { return xidToString(this); }
/** * Does nothing, since we don't do heuristics. */ @Override public void forget(Xid xid) throws XAException { throw new PGXAException(GT.tr("Heuristic commit/rollback not supported. forget xid={0}", xid), XAException.XAER_NOTA); }
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { Reference ref = (Reference) obj; String className = ref.getClassName(); if (className.equals("org.postgresql.xa.PGXADataSource")) { return loadXADataSource(ref); } else { return null; } }
private int mapSQLStateToXAErrorCode(SQLException sqlException) { if (isPostgreSQLIntegrityConstraintViolation(sqlException)) { return XAException.XA_RBINTEGRITY; } return XAException.XAER_RMFAIL; }
public void commit(Xid xid, boolean onePhase) throws XAException { if (logger.logDebug()) debug("committing xid = " + xid + (onePhase ? " (one phase) " : " (two phase)")); if (xid == null) throw new PGXAException(GT.tr("xid must not be null"), XAException.XAER_INVAL); if (onePhase) commitOnePhase(xid); else commitPrepared(xid); }
private Object loadXADataSource(Reference ref) { PGXADataSource ds = new PGXADataSource(); return loadBaseDataSource(ds, ref); } }
@SneakyThrows @Override public XAConnection wrap(final XADataSource xaDataSource, final Connection connection) { BaseConnection physicalConnection = (BaseConnection) connection.unwrap(Class.forName("org.postgresql.core.BaseConnection")); return new PGXAConnection(physicalConnection); } }
PGXAException(Throwable cause, int errorCode) { super(errorCode); initCause(cause); } }
/** * This is for debugging purposes only */ public String toString() { return xidToString(this); }
/** * Does nothing, since we don't do heuristics, */ public void forget(Xid xid) throws XAException { throw new PGXAException(GT.tr("Heuristic commit/rollback not supported"), XAException.XAER_NOTA); }
/** * Gets a XA-enabled connection to the PostgreSQL database. The database is identified by the * DataSource properties serverName, databaseName, and portNumber. The user to connect as is * identified by the arguments user and password, which override the DataSource properties by the * same name. * * @return A valid database connection. * @throws SQLException Occurs when the database connection cannot be established. */ public XAConnection getXAConnection(String user, String password) throws SQLException { Connection con = super.getConnection(user, password); return new PGXAConnection((BaseConnection) con); }
PGXAException(String message, Throwable cause, int errorCode) { super(message); initCause(cause); this.errorCode = errorCode; }
/** * Gets a XA-enabled connection to the PostgreSQL database. The database is identified by the * DataSource properties serverName, databaseName, and portNumber. The user to * connect as is identified by the arguments user and password, which override * the DataSource properties by the same name. * * @return A valid database connection. * @throws SQLException * Occurs when the database connection cannot be established. */ public XAConnection getXAConnection(String user, String password) throws SQLException { Connection con = super.getConnection(user, password); return new PGXAConnection((BaseConnection) con); }
PGXAException(Throwable cause, int errorCode) { super(errorCode); initCause(cause); } }