File: PGXADataSource.java

package info (click to toggle)
libpgjava 8.2-504-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,600 kB
  • ctags: 4,442
  • sloc: java: 31,862; xml: 3,116; makefile: 18; sh: 10
file content (53 lines) | stat: -rw-r--r-- 1,865 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.postgresql.xa;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Referenceable;
import javax.sql.XAConnection;
import javax.sql.XADataSource;

import org.postgresql.core.BaseConnection;
import org.postgresql.ds.common.BaseDataSource;

/**
 * XA-enabled DataSource implementation.
 *
 * @author Heikki Linnakangas (heikki.linnakangas@iki.fi)
 */
public class PGXADataSource extends BaseDataSource implements Referenceable, XADataSource
{
    /**
     * 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());
    }

    /**
     * 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);
    }

    public String getDescription() {
        return "JDBC3 XA-enabled DataSource from " + org.postgresql.Driver.getVersion();
    }
}