com.sage.accpac.sm
Class DBLink

java.lang.Object
  extended by com.sage.accpac.sm.DBLink

@ThreadSafe
public final class DBLink
extends java.lang.Object

Represents a database link or connection to a Sage Accpac ERP company or system database.
An object of this class cannot be created directly by applications. Instead, it should be obtained from the Program object's openDBLink method.
The caller must call the dispose method when finished with the object so that all its resources can be released. The caller must not call any other method on the object after calling dispose.

Thread safety
Thread-safe

Nested Class Summary
static class DBLink.DatabaseType
          This class defines all the database types used by Accpac
static class DBLink.LinkFlags
           
static class DBLink.LinkType
           
 
Method Summary
 void dispose()
          Closes and releases all resources used by the object.
protected  void finalize()
          overrides the finalize method of object so that the dispose gets called if it hasn't already
 Currency getCurrency(java.lang.String currencyCode)
          Gets a Currency object representing the specified currency in the context of the program
 CurrencyRate getCurrencyRate(java.lang.String homeCurrency, java.lang.String rateType, java.lang.String sourceCurrency, java.util.Date date)
          Gets the exchange rate between the specified currencies
 CurrencyRate getCurrencyRateComposite(java.lang.String homeCurrency, java.lang.String rateType, java.lang.String sourceCurrency, java.util.Date date)
          Gets the composite exchange rate between the specified currencies
 CurrencyRate getCurrencyRateFloating(java.lang.String homeCurrency, java.lang.String rateType, java.lang.String sourceCurrency, java.util.Date date)
          Gets the floating exchange rate between the specified currencies, that is the exchange rate between the block master currencies (or the actual currency if it is not a member of a currency block).
 CurrencyTable getCurrencyTable(java.lang.String currency, java.lang.String type)
          gets a new CurrencyTable object for the given currency and type
 DBLink.DatabaseType getDatabaseType()
          Return the database type
 java.sql.ResultSet getDirectQuery(java.lang.String query)
          gets a new ResultSet containing the result of running the query directly against the database.
 DBLink.LinkFlags getFlags()
          gets the database flags used to open the link.
 Program getParent()
          gets the Program object that is the parent of this object
 DBTableMetaData getTableMetaData(java.lang.String tableName)
          Get table meta data by calling native A4WAPIs
 int getTransactionLevel()
          Gets the current transaction level on the current database connection
 DBLink.LinkType getType()
          gets the type of database that the link connects to
 boolean isPermitted(java.lang.String resource)
          returns whether or not the user is permitted to access the given security resource.
 View openView(java.lang.String viewid)
          open an Accpac view
 View openView(java.lang.String viewid, int modes, int prefetch, int directives)
          open an Accpac view.
 int transactionBegin()
          Begins a transaction on the current database connection
 int transactionCommit()
          Commits the most recent transaction on the current database connection
 int transactionRollback()
          Rolls back the most recent transaction on the current database connection
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

dispose

public void dispose()
Closes and releases all resources used by the object. Do not call any methods after calling this.


getCurrency

public Currency getCurrency(java.lang.String currencyCode)
Gets a Currency object representing the specified currency in the context of the program

Parameters:
currencyCode - the code of the currency to be retrieved. The code must consist only of valid ASCII characters.
Returns:
a currency object that represents the currency
Throws:
java.lang.NullPointerException - if the program has been disposed of
java.lang.IllegalArgumentException - if the code does not represent a currency in the program's data

getCurrencyRate

public CurrencyRate getCurrencyRate(java.lang.String homeCurrency,
                                    java.lang.String rateType,
                                    java.lang.String sourceCurrency,
                                    java.util.Date date)
Gets the exchange rate between the specified currencies

Parameters:
homeCurrency - home (functional) currency code
rateType - currency rate type code
sourceCurrency - source currency code
date - date for which the exchange rate should be found
Returns:
a CurrencyRate object that contains the details of the requested exchange rate

getCurrencyRateComposite

public CurrencyRate getCurrencyRateComposite(java.lang.String homeCurrency,
                                             java.lang.String rateType,
                                             java.lang.String sourceCurrency,
                                             java.util.Date date)
Gets the composite exchange rate between the specified currencies

Parameters:
homeCurrency - home (functional) currency code
rateType - currency rate type code
sourceCurrency - source currency code
date - date for which the exchange rate should be found
Returns:
a CurrencyRate object that contains the details of the requested exchange rate

getCurrencyRateFloating

public CurrencyRate getCurrencyRateFloating(java.lang.String homeCurrency,
                                            java.lang.String rateType,
                                            java.lang.String sourceCurrency,
                                            java.util.Date date)
Gets the floating exchange rate between the specified currencies, that is the exchange rate between the block master currencies (or the actual currency if it is not a member of a currency block).

Parameters:
homeCurrency - home (functional) currency code
rateType - currency rate type code
sourceCurrency - source currency code
date - date for which the exchange rate should be found
Returns:
a CurrencyRate object that contains the details of the requested exchange rate
Throws:
java.lang.NullPointerException - if dispose() has been called on the program
java.lang.IllegalArgumentException - if the currency table for the home block master currency and rate code is found but it does not contain exchange rate information for the source block master currency
A4wapiGenericError - if the currency table for the home block master currency and rate code is not found (or some other error occurs)

getCurrencyTable

public CurrencyTable getCurrencyTable(java.lang.String currency,
                                      java.lang.String type)
gets a new CurrencyTable object for the given currency and type


getDirectQuery

public java.sql.ResultSet getDirectQuery(java.lang.String query)
gets a new ResultSet containing the result of running the query directly against the database.


getParent

public Program getParent()
gets the Program object that is the parent of this object


getTransactionLevel

public int getTransactionLevel()
Gets the current transaction level on the current database connection

Returns:
The current transaction level
Throws:
DBLinkException - If a database error occurs.

getFlags

public DBLink.LinkFlags getFlags()
gets the database flags used to open the link. The flags control the access mode of the database connection.


getType

public DBLink.LinkType getType()
gets the type of database that the link connects to


isPermitted

public boolean isPermitted(java.lang.String resource)
returns whether or not the user is permitted to access the given security resource.

Parameters:
resource - the name of the resource to be checked. This must consist of only ASCII printable characters at may be at most 10 characters long.
Returns:
true if and only if the user is permitted to access the given resource.

openView

public View openView(java.lang.String viewid,
                     int modes,
                     int prefetch,
                     int directives)
open an Accpac view.

Parameters:
... - The parameters are as for the View constructor.
Returns:
a new view

openView

public View openView(java.lang.String viewid)
open an Accpac view

Parameters:
viewid - the rotoid of the view to open
Returns:
a new view

transactionBegin

public int transactionBegin()
Begins a transaction on the current database connection

Returns:
The transaction level after the transaction has begun
Throws:
DBLinkException - If a database error occurs.

transactionCommit

public int transactionCommit()
Commits the most recent transaction on the current database connection

Returns:
The transaction level after the transaction was committed
Throws:
java.lang.IllegalStateException - If the connection is not currently in a transaction
DBLinkException - If a database error occurs

transactionRollback

public int transactionRollback()
Rolls back the most recent transaction on the current database connection

Returns:
The transaction level after the transaction was rolled back
Throws:
DBLinkException - If a database error occurs.

getTableMetaData

public DBTableMetaData getTableMetaData(java.lang.String tableName)
Get table meta data by calling native A4WAPIs

Parameters:
tableName - - the name of an ACCPAC database table
Returns:
ResultSetMetaData
Throws:
DBLinkException - If a database error occurs

getDatabaseType

public DBLink.DatabaseType getDatabaseType()
Return the database type

Returns:
one of the database types defined in the DatabaseType class

finalize

protected void finalize()
overrides the finalize method of object so that the dispose gets called if it hasn't already

Overrides:
finalize in class java.lang.Object


Copyright © 2010 Sage Software, Inc. All rights reserved.