/** * Sets properties from a {@link DriverManager} URL. * Added to follow convention used in other DBMS. * * @param url properties to set */ public void setURL(String url) { setUrl(url); }
/** * Generates a {@link DriverManager} URL from the other properties supplied. * * @return {@link DriverManager} URL from the other properties supplied */ public String getURL() { return getUrl(); }
/** * 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 Connection getConnection() throws SQLException { return getConnection(user, password); }
protected Object loadBaseDataSource(BaseDataSource ds, Reference ref) { ds.setDatabaseName(getProperty(ref, "databaseName")); ds.setPassword(getProperty(ref, "password")); String port = getProperty(ref, "portNumber"); if (port != null) { ds.setPortNumber(Integer.parseInt(port)); } ds.setServerName(getProperty(ref, "serverName")); ds.setUser(getProperty(ref, "user")); String prepareThreshold = getProperty(ref, "prepareThreshold"); if (prepareThreshold != null) ds.setPrepareThreshold(Integer.parseInt(prepareThreshold)); return ds; }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }
/** * Ensures the DataSource properties are not changed after the DataSource has been used. * * @throws IllegalStateException The Port Number cannot be changed after the DataSource has been * used. */ public void setPortNumber(int portNumber) { if (initialized) { throw new IllegalStateException( "Cannot set Data Source properties after DataSource has been used"); } super.setPortNumber(portNumber); }
/** * Ensures the DataSource properties are not changed after the DataSource has been used. * * @throws IllegalStateException The User cannot be changed after the DataSource has been used. */ public void setUser(String user) { if (initialized) { throw new IllegalStateException( "Cannot set Data Source properties after DataSource has been used"); } super.setUser(user); }
/** * Ensures the DataSource properties are not changed after the DataSource has been used. * * @throws IllegalStateException The Password cannot be changed after the DataSource has been * used. */ public void setPassword(String password) { if (initialized) { throw new IllegalStateException( "Cannot set Data Source properties after DataSource has been used"); } super.setPassword(password); }
/** * Ensures the DataSource properties are not changed after the DataSource has been used. * * @throws IllegalStateException The Database Name cannot be changed after the DataSource has been * used. */ public void setDatabaseName(String databaseName) { if (initialized) { throw new IllegalStateException( "Cannot set Data Source properties after DataSource has been used"); } super.setDatabaseName(databaseName); }
/** * Ensures the DataSource properties are not changed after the DataSource has been used. * * @throws IllegalStateException The Server Name cannot be changed after the DataSource has been * used. */ public void setServerName(String serverName) { if (initialized) { throw new IllegalStateException( "Cannot set Data Source properties after DataSource has been used"); } super.setServerName(serverName); }
public void setFromReference(Reference ref) { databaseName = getReferenceProperty(ref, "databaseName"); String port = getReferenceProperty(ref, "portNumber"); if (port != null) { portNumber = Integer.parseInt(port); } serverName = getReferenceProperty(ref, "serverName"); for (PGProperty property : PGProperty.values()) { setProperty(property, getReferenceProperty(ref, property.getName())); } }
protected Object loadBaseDataSource(BaseDataSource ds, Reference ref) { ds.setFromReference(ref); return ds; }
/** * Sets properties from a {@link DriverManager} URL. * * @param url properties to set */ public void setUrl(String url) { Properties p = org.postgresql.Driver.parseURL(url, null); for (PGProperty property : PGProperty.values()) { setProperty(property, property.get(p)); } }
/** * 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 Connection getConnection() throws SQLException { return getConnection(user, password); }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
/** * Ensures the DataSource properties are not changed after the DataSource has * been used. * * @throws java.lang.IllegalStateException * The Port Number cannot be changed after the DataSource has been * used. */ public void setPortNumber(int portNumber) { if (initialized) { throw new IllegalStateException("Cannot set Data Source properties after DataSource has been used"); } super.setPortNumber(portNumber); }
/** * 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); }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }
/** * 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); }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }