org.firebirdsql.gds.impl
Class GDSHelper

java.lang.Object
  extended by org.firebirdsql.gds.impl.GDSHelper

public class GDSHelper
extends Object

Helper class for all GDS-related operations.


Nested Class Summary
static interface GDSHelper.GDSHelperErrorListener
          Notification listener about any error that occured in this class.
 
Field Summary
static byte[] BLOB_LENGTH_REQUEST
           
static int DEFAULT_BLOB_BUFFER_SIZE
           
protected  DatabaseParameterBuffer dpb
          Needed from mcf when killing a db handle when a new tx cannot be started.
 
Constructor Summary
GDSHelper(GDS gds, DatabaseParameterBuffer dpb, AbstractIscDbHandle dbHandle, GDSHelper.GDSHelperErrorListener listener)
          Create instance of this class.
 
Method Summary
 AbstractIscStmtHandle allocateStatement()
          Retrieve a newly allocated statment handle with the current connection.
 void clearWarnings()
          Clear warnings for this database connection.
 void closeBlob(IscBlobHandle blob)
          Close a blob that has been opened within the database.
 void closeStatement(AbstractIscStmtHandle stmt, boolean deallocate)
          Close a statement that is allocated in the database.
 void commitTransaction(AbstractIscTrHandle trHandle)
           
 IscBlobHandle createBlob(boolean segmented)
          Create a new blob within the current transaction.
 void detachDatabase()
           
 void executeImmediate(String statement)
          Execute a SQL statement directly with the current connection.
 void executeStatement(AbstractIscStmtHandle stmt, boolean sendOutSqlda)
          Execute a statement in the database.
 void fetch(AbstractIscStmtHandle stmt, int fetchSize)
          Fetch data from a statement in the database.
 int getBlobBufferLength()
          Get the buffer length for blobs for this connection.
 byte[] getBlobInfo(IscBlobHandle blob, byte[] requestItems, int bufferLength)
           
 int getBlobLength(IscBlobHandle blob)
           
 byte[] getBlobSegment(IscBlobHandle blob, int len)
          Get a segment from a blob.
 IscDbHandle getCurrentDbHandle()
           
 AbstractIscTrHandle getCurrentTrHandle()
           
 DatabaseParameterBuffer getDatabaseParameterBuffer()
           
 int getDatabaseProductMajorVersion()
          Get the major version number of the database that we're connected to.
 int getDatabaseProductMinorVersion()
          Get the minor version number of the database that we're connected to.
 String getDatabaseProductName()
          Get the name of the database product that we're connected to.
 String getDatabaseProductVersion()
          Get the version of the the database that we're connected to
 GDS getInternalAPIHandler()
          Get Firebird API handler (sockets/native/embeded/etc)
 IscDbHandle getIscDBHandle()
          Get connection handle for direct Firebird API access
 String getIscEncoding()
          Get the encoding used for this connection.
 String getJavaEncoding()
           
 String getMappingPath()
           
 void getSqlCounts(AbstractIscStmtHandle stmt)
          Fetch the count information for a statement handle.
 int getTransactionId(IscTrHandle trHandle)
           
 String getUserName()
          Get the database login name of the user that we're connected as.
 List getWarnings()
          Get all warnings associated with current connection.
 boolean inTransaction()
          Retrieve whether this connection is currently involved in a transaction
 int iscVaxInteger(byte[] buffer, int pos, int length)
           
 IscBlobHandle openBlob(long blob_id, boolean segmented)
          Open a handle to a new blob within the current transaction with the given id.
 void populateStatementInfo(AbstractIscStmtHandle fixedStmt)
           
 void prepareStatement(AbstractIscStmtHandle stmt, String sql, boolean describeBind)
          Prepare an SQL string for execution (within the database server) in the context of a statement handle.
 void prepareTransaction(AbstractIscTrHandle trHandle, byte[] message)
           
 void putBlobSegment(IscBlobHandle blob, byte[] buf)
          Write a segment of data to a blob.
 void rollbackTransaction(AbstractIscTrHandle trHandle)
           
 void seekBlob(IscBlobHandle blob, int position, int mode)
           
 void setCurrentTrHandle(AbstractIscTrHandle currentTr)
           
 void setCursorName(AbstractIscStmtHandle stmt, String cursorName)
          Set the cursor name for a statement.
 AbstractIscTrHandle startTransaction(TransactionParameterBuffer tpb)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BLOB_BUFFER_SIZE

public static final int DEFAULT_BLOB_BUFFER_SIZE
See Also:
Constant Field Values

dpb

protected DatabaseParameterBuffer dpb
Needed from mcf when killing a db handle when a new tx cannot be started.


BLOB_LENGTH_REQUEST

public static final byte[] BLOB_LENGTH_REQUEST
Constructor Detail

GDSHelper

public GDSHelper(GDS gds,
                 DatabaseParameterBuffer dpb,
                 AbstractIscDbHandle dbHandle,
                 GDSHelper.GDSHelperErrorListener listener)
Create instance of this class.

Method Detail

getCurrentTrHandle

public AbstractIscTrHandle getCurrentTrHandle()

setCurrentTrHandle

public void setCurrentTrHandle(AbstractIscTrHandle currentTr)

getCurrentDbHandle

public IscDbHandle getCurrentDbHandle()

getDatabaseParameterBuffer

public DatabaseParameterBuffer getDatabaseParameterBuffer()

allocateStatement

public AbstractIscStmtHandle allocateStatement()
                                        throws GDSException
Retrieve a newly allocated statment handle with the current connection.

Returns:
The new statement handle
Throws:
GDSException - if a database access error occurs

inTransaction

public boolean inTransaction()
Retrieve whether this connection is currently involved in a transaction

Returns:
true if this connection is currently in a transaction, false otherwise.

getTransactionId

public int getTransactionId(IscTrHandle trHandle)
                     throws GDSException
Throws:
GDSException

prepareStatement

public void prepareStatement(AbstractIscStmtHandle stmt,
                             String sql,
                             boolean describeBind)
                      throws GDSException,
                             SQLException
Prepare an SQL string for execution (within the database server) in the context of a statement handle.

Parameters:
stmt - The statement handle within which the SQL statement will be prepared
sql - The SQL statement to be prepared
describeBind - Send bind data to the database server
Throws:
GDSException - if a Firebird-specific error occurs
SQLException - if a database access error occurs

executeStatement

public void executeStatement(AbstractIscStmtHandle stmt,
                             boolean sendOutSqlda)
                      throws GDSException
Execute a statement in the database.

Parameters:
stmt - The handle to the statement to be executed
sendOutSqlda - Determines if the XSQLDA structure should be sent to the database
Throws:
GDSException - if a Firebird-specific error occurs

executeImmediate

public void executeImmediate(String statement)
                      throws GDSException
Execute a SQL statement directly with the current connection.

Parameters:
statement - The SQL statement to execute
Throws:
GDSException - if a Firebird-specific error occurs

fetch

public void fetch(AbstractIscStmtHandle stmt,
                  int fetchSize)
           throws GDSException
Fetch data from a statement in the database.

Parameters:
stmt - handle to the statement from which data will be fetched
fetchSize - The number of records to fetch
Throws:
GDSException - if a Firebird-specific error occurs

setCursorName

public void setCursorName(AbstractIscStmtHandle stmt,
                          String cursorName)
                   throws GDSException
Set the cursor name for a statement.

Parameters:
stmt - handle to statement for which the cursor name will be set
cursorName - the name for the cursor
Throws:
GDSException - if a Firebird-specific database access error occurs

closeStatement

public void closeStatement(AbstractIscStmtHandle stmt,
                           boolean deallocate)
                    throws GDSException
Close a statement that is allocated in the database. The statement can be optionally deallocated.

Parameters:
stmt - handle to the statement to be closed
deallocate - if true, the statement will be deallocated, otherwise it will not be deallocated
Throws:
GDSException - if a Firebird-specific database access error occurs

getSqlCounts

public void getSqlCounts(AbstractIscStmtHandle stmt)
                  throws GDSException
Fetch the count information for a statement handle. The count information that is updated includes the counts for update, insert, delete and select, and it is set in the handle itself.

Parameters:
stmt - handle to the statement for which counts will be fetched
Throws:
GDSException - if a Firebird-specific database access error occurs

populateStatementInfo

public void populateStatementInfo(AbstractIscStmtHandle fixedStmt)
                           throws GDSException
Throws:
GDSException

openBlob

public IscBlobHandle openBlob(long blob_id,
                              boolean segmented)
                       throws GDSException
Open a handle to a new blob within the current transaction with the given id.

Parameters:
blob_id - The identifier to be given to the blob
segmented - If true, the blob will be segmented, otherwise is will be streamed
Throws:
GDSException - if a Firebird-specific database error occurs

createBlob

public IscBlobHandle createBlob(boolean segmented)
                         throws GDSException
Create a new blob within the current transaction.

Parameters:
segmented - If true the blob will be segmented, otherwise it will be streamed
Throws:
GDSException - if a Firebird-specific database error occurs

getBlobSegment

public byte[] getBlobSegment(IscBlobHandle blob,
                             int len)
                      throws GDSException
Get a segment from a blob.

Parameters:
blob - Handle to the blob from which the segment is to be fetched
len - The maximum length to fetch
Throws:
GDSException - if a Firebird-specific database access error occurs

closeBlob

public void closeBlob(IscBlobHandle blob)
               throws GDSException
Close a blob that has been opened within the database.

Parameters:
blob - Handle to the blob to be closed
Throws:
GDSException - if a Firebird-specific database access error occurs

seekBlob

public void seekBlob(IscBlobHandle blob,
                     int position,
                     int mode)
              throws GDSException
Throws:
GDSException

putBlobSegment

public void putBlobSegment(IscBlobHandle blob,
                           byte[] buf)
                    throws GDSException
Write a segment of data to a blob.

Parameters:
blob - handle to the blob to which data will be written
buf - segment of data to be written to the blob
Throws:
GDSException - if a Firebird-specific database access error occurs

getBlobInfo

public byte[] getBlobInfo(IscBlobHandle blob,
                          byte[] requestItems,
                          int bufferLength)
                   throws GDSException
Throws:
GDSException

getBlobLength

public int getBlobLength(IscBlobHandle blob)
                  throws GDSException
Throws:
GDSException

startTransaction

public AbstractIscTrHandle startTransaction(TransactionParameterBuffer tpb)
                                     throws GDSException
Throws:
GDSException

prepareTransaction

public void prepareTransaction(AbstractIscTrHandle trHandle,
                               byte[] message)
                        throws GDSException
Throws:
GDSException

commitTransaction

public void commitTransaction(AbstractIscTrHandle trHandle)
                       throws GDSException
Throws:
GDSException

rollbackTransaction

public void rollbackTransaction(AbstractIscTrHandle trHandle)
                         throws GDSException
Throws:
GDSException

detachDatabase

public void detachDatabase()
                    throws GDSException
Throws:
GDSException

iscVaxInteger

public int iscVaxInteger(byte[] buffer,
                         int pos,
                         int length)

getDatabaseProductName

public String getDatabaseProductName()
Get the name of the database product that we're connected to.

Returns:
The database product name (i.e. Firebird or Interbase)

getDatabaseProductVersion

public String getDatabaseProductVersion()
Get the version of the the database that we're connected to

Returns:
the database product version

getDatabaseProductMajorVersion

public int getDatabaseProductMajorVersion()
Get the major version number of the database that we're connected to.

Returns:
The major version number of the database

getDatabaseProductMinorVersion

public int getDatabaseProductMinorVersion()
Get the minor version number of the database that we're connected to.

Returns:
The minor version number of the database

getUserName

public String getUserName()
Get the database login name of the user that we're connected as.

Returns:
The username of the current database user

getBlobBufferLength

public int getBlobBufferLength()
Get the buffer length for blobs for this connection.

Returns:
The length of blob buffers

getIscEncoding

public String getIscEncoding()
Get the encoding used for this connection.

Returns:
The name of the encoding used

getJavaEncoding

public String getJavaEncoding()

getMappingPath

public String getMappingPath()

getWarnings

public List getWarnings()
Get all warnings associated with current connection.

Returns:
list of GDSExceptioninstances representing warnings for this database connection.

clearWarnings

public void clearWarnings()
Clear warnings for this database connection.


getIscDBHandle

public IscDbHandle getIscDBHandle()
Get connection handle for direct Firebird API access

Returns:
internal handle for connection

getInternalAPIHandler

public GDS getInternalAPIHandler()
Get Firebird API handler (sockets/native/embeded/etc)

Returns:
handler object for internal API calls


Copyright © 2001-2010. All Rights Reserved.