Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: FBAbstractCommonDataSource.java 57608 2013-01-19 14:14:44Z mrotteveel $
   * 
   * Firebird Open Source J2EE Connector - JDBC Driver
   *
   * Distributable under LGPL license.
   * You may obtain a copy of the License at http://www.gnu.org/copyleft/lgpl.html
   *
   * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * LGPL License for more details.
  *
  * This file was created by members of the firebird development team.
  * All individual contributions remain the Copyright (C) of those
  * individuals.  Contributors to this file are either listed here or
  * can be obtained from a CVS history command.
  *
  * All rights reserved.
  */
 package org.firebirdsql.ds;
 
 
 
Abstract class for properties and behaviour common to DataSources, XADataSources and ConnectionPoolDataSources

Author(s):
Mark Rotteveel
Since:
2.2
 
 public abstract class FBAbstractCommonDataSource extends RootCommonDataSource implements FirebirdConnectionProperties {
 
     protected static final String REF_DATABASE_NAME = "databaseName";
     protected static final String REF_PORT_NUMBER = "portNumber";
     protected static final String REF_SERVER_NAME = "serverName";
     protected static final String REF_DESCRIPTION = "description";
     protected static final String REF_PROPERTIES = "properties";
     
     private String description;
     private String serverName;
     private int portNumber;
     private String databaseName;
     protected final Object lock = new Object();
Method to check if this DataSource has not yet started.

Implementations should throw IllegalStateException when the DataSource is already in use and modifying properties is not allowed.

Throws:
java.lang.IllegalStateException When the DataSource is already in use
 
     protected abstract void checkNotStarted() throws IllegalStateException;
 
     public String getDescription() {
         return ;
     }
 
     public void setDescription(String description) {
         this. = description;
     }
 
     public final String getServerName() {
         synchronized () {
             return ;
         }
     }
 
     public final void setServerName(String serverName) {
         synchronized () {
             checkNotStarted();
             this. = serverName;
             setDatabase();
         }
     }
 
     public final int getPortNumber() {
         synchronized () {
             return ;
         }
     }
 
     public final void setPortNumber(int portNumber) {
         synchronized () {
             checkNotStarted();
             this. = portNumber;
            setDatabase();
        }
    }
    public final String getDatabaseName() {
        synchronized () {
            return ;
        }
    }

    
Sets the databaseName of this datasource.

The databaseName is the filepath or alias of the database only, so it should not include serverName and portNumber.

Parameters:
databaseName Databasename (filepath or alias)
    public final void setDatabaseName(String databaseName) {
        synchronized () {
            checkNotStarted();
            this. = databaseName;
            setDatabase();
        }
    }
    public final String getType() {
        synchronized () {
            return .getType();
        }
    }
    public final void setType(String type) {
        synchronized () {
            checkNotStarted();
            .setType(type);
        }
    }
    public String getUser() {
        return .getUserName();
    }
    public void setUser(String user) {
        .setUserName(user);
    }
    public String getPassword() {
        return .getPassword();
    }
    public String getRoleName() {
        return .getRoleName();
    }
    public void setRoleName(String roleName) {
        .setRoleName(roleName);
    }
    public void setPassword(String password) {
        .setPassword(password);
    }
    public final String getCharSet() {
        synchronized () {
            return .getCharSet();
        }
    }

    

Parameters:
charSet Character set for the connection. Similar to encoding property, but accepts Java names instead of Firebird ones.
    public final void setCharSet(String charSet) {
        synchronized () {
            checkNotStarted();
            .setCharSet(charSet);
        }
    }
    public final String getEncoding() {
        synchronized () {
            return .getEncoding();
        }
    }

    

Parameters:
encoding Firebird name of the character encoding for the connection. See Firebird documentation for more information.
    public final void setEncoding(String encoding) {
        synchronized () {
            checkNotStarted();
            .setEncoding(encoding);
        }
    }

    

This property is an alias for the connectTimeout property.

    public int getLoginTimeout() throws SQLException {
    	return getConnectTimeout();
    }

    

This property is an alias for the connectTimeout property.

    public void setLoginTimeout(int secondsthrows SQLException {
    	setConnectTimeout(seconds);
    }
    
    public int getConnectTimeout() {
        return .getConnectTimeout();
    }
    
    public void setConnectTimeout(int connectTimeout) {
        .setConnectTimeout(connectTimeout);
    }
    
    @Deprecated
    public String getDatabase() {
        synchronized() {
            return .getDatabase();
        }
    }
    @Deprecated
    public void setDatabase(String database) {
        synchronized() {
            // TODO: Try to set databaseName, portNumber and serverName?
            .setDatabase(database);
        }
    }
    public int getBlobBufferSize() {
        return .getBlobBufferSize();
    }
    public void setBlobBufferSize(int bufferSize) {
        checkNotStarted();
        .setBlobBufferSize(bufferSize);
    }
    public String getSqlDialect() {
        return .getSqlDialect();
    }
    public void setSqlDialect(String sqlDialect) {
        checkNotStarted();
        .setSqlDialect(sqlDialect);
    }
    public String getUseTranslation() {
        synchronized() {
            return .getUseTranslation();
        }
    }
    public void setUseTranslation(String translationPath) {
        synchronized() {
            checkNotStarted();
            .setUseTranslation(translationPath);
        }
    }
    public boolean isUseStreamBlobs() {
        return .isUseStreamBlobs();
    }
    public void setUseStreamBlobs(boolean useStreamBlobs) {
        checkNotStarted();
        .setUseStreamBlobs(useStreamBlobs);
    }
    public boolean isUseStandardUdf() {
        return .isUseStandardUdf();
    }
    public void setUseStandardUdf(boolean useStandardUdf) {
        checkNotStarted();
        .setUseStandardUdf(useStandardUdf);
    }
    public int getSocketBufferSize() {
        return .getSocketBufferSize();
    }
    public void setSocketBufferSize(int socketBufferSize) {
        checkNotStarted();
        .setSocketBufferSize(socketBufferSize);
    }
    public boolean isTimestampUsesLocalTimezone() {
    }
    public void setTimestampUsesLocalTimezone(boolean timestampUsesLocalTimezone) {
        checkNotStarted();
        .setTimestampUsesLocalTimezone(timestampUsesLocalTimezone);
    }
    @Deprecated
    public String getUserName() {
        return getUser();
    }
    @Deprecated
    public void setUserName(String userName) {
        setUser(userName);
    }
    public int getBuffersNumber() {
        return .getBuffersNumber();
    }
    public void setBuffersNumber(int buffersNumber) {
        checkNotStarted();
        .setBuffersNumber(buffersNumber);
    }
    }
    public String getTpbMapping() {
        return .getTpbMapping();
    }
    public void setTpbMapping(String tpbMapping) {
        checkNotStarted();
        .setTpbMapping(tpbMapping);
    }
    public int getDefaultTransactionIsolation() {
    }
    public void setDefaultTransactionIsolation(int defaultIsolationLevel) {
        checkNotStarted();
        .setDefaultTransactionIsolation(defaultIsolationLevel);
    }
    public String getDefaultIsolation() {
        return .getDefaultIsolation();
    }
    public void setDefaultIsolation(String isolation) {
        checkNotStarted();
        .setDefaultIsolation(isolation);
    }
    public TransactionParameterBuffer getTransactionParameters(int isolation) {
        return .getTransactionParameters(isolation);
    }
    public void setTransactionParameters(int isolationTransactionParameterBuffer tpb) {
        checkNotStarted();
        .setTransactionParameters(isolationtpb);
    }
    public boolean isDefaultResultSetHoldable() {
    }
    public void setDefaultResultSetHoldable(boolean isHoldable) {
        checkNotStarted();
    }
    public int getSoTimeout() {
        return .getSoTimeout();
    }
    public void setSoTimeout(int soTimeout) {
        checkNotStarted();
        .setSoTimeout(soTimeout);
    }
    
    
Method that allows setting non-standard property in the form "key=value" form. This method is needed by some containers to specify properties in the configuration.

Parameters:
propertyMapping mapping between property name (key) and its value. Name and value are separated with "=", ":" or whitespace character. Whitespace characters on the beginning of the string and between key and value are ignored. No escaping is possible: "\n" is backslash-en, not a new line mark.
See also:
setNonStandardProperty(java.lang.String,java.lang.String)
    public final void setNonStandardProperty(String propertyMapping) {
        checkNotStarted();
        .setNonStandardProperty(propertyMapping);
    }
    
    
Method to set properties which are not exposed through JavaBeans-style setters.

Parameters:
key Name of the property (see Jaybird releasenotes)
value Value of the property
See also:
setNonStandardProperty(java.lang.String)
    public final void setNonStandardProperty(String keyString value) {
        checkNotStarted();
        .setNonStandardProperty(keyvalue);
    }
    
    
Method to get the value of properties which are not exposed through JavaBeans-style setters.

Parameters:
key Name of the property (see Jaybird releasenotes)
Returns:
Value of the property
See also:
setNonStandardProperty(java.lang.String)
setNonStandardProperty(java.lang.String,java.lang.String)
    public final String getNonStandardProperty(String key) {
        return .getNonStandardProperty(key);
    }

    
Sets the database property of connectionProperties.
    protected final void setDatabase() {
        // TODO: Not 100% sure if this works for all GDSTypes, may need to defer
        // to getDatabasePath of the relevant GDSFactoryPlugin
        StringBuilder sb = new StringBuilder();
        if ( != null && .length() > 0) {
            sb.append("//").append();
            if ( > 0) {
                sb.append(':').append();
            }
            sb.append('/');
        }
        if ( != null) {
            sb.append();
        }
        if (sb.length() > 0) {
            .setDatabase(sb.toString());
        } else {
            .setDatabase(null);
        }
    }
    
    protected final void setConnectionProperties(FBConnectionProperties connectionProperties) {
        this. = connectionProperties;
    }
    
    protected final FBConnectionProperties getConnectionProperties() {
        return ;
    }
    
    
Updates the supplied reference with RefAddr properties relevant to this class.

Parameters:
ref Reference to update
instance Instance of this class to obtain values
    protected static void updateReference(Reference refFBAbstractCommonDataSource instance) {
        ref.add(new StringRefAddr(instance.getDescription()));
        ref.add(new StringRefAddr(instance.getServerName()));
        if (instance.getPortNumber() != 0) {
            ref.add(new StringRefAddr(, Integer.toString(instance.getPortNumber())));
        }
        ref.add(new StringRefAddr(instance.getDatabaseName()));
        byte[] data = DataSourceFactory.serialize(instance.connectionProperties);
        ref.add(new BinaryRefAddr(data));
    }
New to GrepCode? Check out our FAQ X