org.firebirdsql.gds.ng

## Class AbstractConnection<T extends IAttachProperties<T>,C extends FbAttachment>

- java.lang.Object
- - org.firebirdsql.gds.ng.AbstractConnection<T,C>

Type Parameters:
  `T` - Type of attach properties
  `C` - Type of connection handle

Direct Known Subclasses:
  JnaConnection, WireConnection

    public abstract class AbstractConnection<T extends IAttachProperties<T>,C extends FbAttachment>
    extends java.lang.Object

Abstract class with common logic for connections.

Since:
  3.0
Author:
  Mark Rotteveel

### Field Summary

Fields
`protected T` `attachProperties`

### Constructor Summary

Constructors
`protected` `AbstractConnection(T attachProperties, IEncodingFactory encodingFactory)`

### Method Summary

Methods
`DbCryptCallback` `createDbCryptCallback()` Creates an instance of `DbCryptCallback` for this connection.
`java.lang.String` `getAttachObjectName()`
`T` `getAttachProperties()`
`Encoding` `getEncoding()`
`EncodingDefinition` `getEncodingDefinition()`
`IEncodingFactory` `getEncodingFactory()`
`int` `getPortNumber()`
`java.lang.String` `getServerName()`
`abstract C` `identify()` Performs the connection identification phase of the protocol and returns the connection handle implementation for the agreed protocol.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### attachProperties

    protected final T extends IAttachProperties<T> attachProperties

### Constructor Detail

#### AbstractConnection

    protected AbstractConnection(T attachProperties,
                      IEncodingFactory encodingFactory)
                          throws java.sql.SQLException

Throws:
  `java.sql.SQLException`

### Method Detail

#### identify

    public abstract C identify()
                                             throws java.sql.SQLException

Performs the connection identification phase of the protocol and returns the connection handle implementation for the agreed protocol.

Returns:
  Connection handle (ie `FbDatabase` or `FbService`)
Throws:
  `java.sql.SQLException` - For exceptions connecting

#### getServerName

    public final java.lang.String getServerName()

#### getPortNumber

    public final int getPortNumber()

#### getAttachObjectName

    public final java.lang.String getAttachObjectName()

#### getAttachProperties

    public final T getAttachProperties()

Returns:
  An immutable copy of the current attach properties.

#### getEncodingDefinition

    public final EncodingDefinition getEncodingDefinition()

#### getEncoding

    public final Encoding getEncoding()

#### getEncodingFactory

    public final IEncodingFactory getEncodingFactory()

#### createDbCryptCallback

    @InternalApi
    public final DbCryptCallback createDbCryptCallback()
                                                throws java.sql.SQLException

Creates an instance of `DbCryptCallback` for this connection.

Returns:
  Database encryption callback.
Throws:
  `java.sql.SQLException` - For errors initializing the callback