javax.infobus
Interface DbAccess


public abstract interface DbAccess

DataItems that implement the DbAccess interface represent a database. The DbAccess interface contains methods to determine what arguments are needed to connect to the database, to connect to and disconnect from the database, to execute retrieval and non-retrieval queries, to control transactions, and to validate changes made to the database.


Method Summary
 void beginTransaction()
          Begin an explicit transaction.
 void commitTransaction()
          Commit all changes made since the last beginTransaction (there may be none) Resume automatically commiting individual row changes.
 void connect()
          Connect to the data source using current connection settings
 void connect(java.lang.String url, java.util.Properties info)
          connect to the specified database URL passing any required connection arguments in a Properties Object.
 void connect(java.lang.String url, java.lang.String username, java.lang.String password)
          Connect to the specified database URL using the specified user ID and password
 void disconnect()
          Disconnect from the database
 int executeCommand(java.lang.String command, java.lang.String dataItemName)
          executes the specified non-retrieval query and returns the count of rows affected, or -1 if this is not applicable (the query does not manipulate rows)
 java.lang.Object executeRetrieval(java.lang.String retrieval, java.lang.String dataItemName, java.lang.String options)
          This method executes the specified retrieval query and returns the result as a DataItem.
 void flush()
          Explicitly propagate all changes to the database without commiting them.
 java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info)
          Discover what connection arguments are required.
 void rollbackTransaction()
          Undo all changes made since the last beginTransaction (there may be none) Resume automatically commiting individual row changes.
 void validate()
          Explicitly validate all changes to the database without committing them.
 

Method Detail

connect

public void connect()
             throws java.sql.SQLException
Connect to the data source using current connection settings
Throws:
java.sql.SQLException - if the query failed

connect

public void connect(java.lang.String url,
                    java.lang.String username,
                    java.lang.String password)
             throws java.sql.SQLException
Connect to the specified database URL using the specified user ID and password
Parameters:
url - the database URL
username - the user ID
passwword - the password
Throws:
java.sql.SQLException - if the query failed

connect

public void connect(java.lang.String url,
                    java.util.Properties info)
             throws java.sql.SQLException
connect to the specified database URL passing any required connection arguments in a Properties Object.
Parameters:
url - the database URL
info - the Properties object containing any required information such as username or password.
Throws:
java.sql.SQLException - if the query failed

disconnect

public void disconnect()
                throws java.sql.SQLException
Disconnect from the database
Throws:
java.sql.SQLException - if the query failed

getPropertyInfo

public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url,
                                                     java.util.Properties info)
Discover what connection arguments are required.
Parameters:
url - database URL
info - proposed connection arguments (may be initially empty)

executeRetrieval

public java.lang.Object executeRetrieval(java.lang.String retrieval,
                                         java.lang.String dataItemName,
                                         java.lang.String options)
                                  throws java.sql.SQLException
This method executes the specified retrieval query and returns the result as a DataItem.
Parameters:
retrieval - the retrieval query; typically a SQL SELECT or a stored procedure which returns a result
dataItemName - if not null, instructs the data provider to make the resulting RowsetAccess item available under the specified name
options - space delimited list of option strings
Returns:
the query results as a DataItem implementing RowsetAccess
Throws:
java.sql.SQLException - if the query failed

executeCommand

public int executeCommand(java.lang.String command,
                          java.lang.String dataItemName)
                   throws java.sql.SQLException
executes the specified non-retrieval query and returns the count of rows affected, or -1 if this is not applicable (the query does not manipulate rows)
Parameters:
command - the non-retrieval command to execute
dataItemName - if not null, instructs the data provider to make the count of affected rows available as an ImmediateAccess DataItem with the specifed name
Throws:
java.sql.SQLException - if the query failed

beginTransaction

public void beginTransaction()
Begin an explicit transaction. Individual row changes will no longer be automatically commited.
Throws:
UnsupportedOperationException - if not supported.

commitTransaction

public void commitTransaction()
                       throws java.sql.SQLException,
                              RowsetValidationException
Commit all changes made since the last beginTransaction (there may be none) Resume automatically commiting individual row changes.
Throws:
UnsupportedOperationException - if not supported.
java.sql.SQLException - if a backend database error occurred
RowsetValidationException - if the data producer detected an invalid change.

rollbackTransaction

public void rollbackTransaction()
                         throws java.sql.SQLException,
                                RowsetValidationException
Undo all changes made since the last beginTransaction (there may be none) Resume automatically commiting individual row changes.
Throws:
UnsupportedOperationException - if not supported.
java.sql.SQLException - if a backend database error occurred
RowsetValidationException - if the data producer detected an invalid change.

validate

public void validate()
              throws java.sql.SQLException,
                     RowsetValidationException
Explicitly validate all changes to the database without committing them. This may be done by the data producer without interacting with the database. Does nothing and does not throw an exception if not supported.
Throws:
java.sql.SQLException - if a backend database error occurred
RowsetValidationException - if the data producer detected an invalid change.

flush

public void flush()
           throws java.sql.SQLException,
                  RowsetValidationException
Explicitly propagate all changes to the database without commiting them. This may encounter exceptions.
Throws:
java.sql.SQLException - if a backend database error occurred
RowsetValidationException - if the data producer detected an invalid change.