Press on the image to return to the main documentation page.
Jackcess
Written by Andrew Graham
This library is based on Jackcess, a pure Java library for reading from and writing to MS Access databases. Presently Access database versions 2000-2010 are supported and Access 97 read-only. It will obviously help to have some knowledge of MS Access in order to understand it. Jackcess does not support SQL queries so all database manipulations are done procedurally.
This library depends on commons-lang-2.6.jar and jackcess-1.2.10.jar. It also requires several files to be present in a myproject\res\raw folder. Those files may be copied from the demo in the archive and must be made read-only.
Jackcess and therefore also this library is licensed under the GNU Lesser General Public License. http://www.gnu.org/licenses/lgpl.html Copies of both the General Public License and Lesser General Public License are in the provided archive.
Moves to the first row (as defined by the cursor) where the given column has the given value. If a match is not found (or an exception is thrown), the cursor is restored to its previous state. Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).
Moves to the next row (as defined by the cursor) where the given column has the given value. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.
GetColumnValue (columnnameAsString) AsObject
Most Access data types map to types directly supported by Basic4android and can be returned as is. Only dates need special treatment to turn them into ticks for the Basic4android DateTime object. Rather than put a check for a Date in every call to this method it is incumbent on the programmer to pass the Date object to the JackcessDatabase.DateToTicks helper method.
Reads the next row into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate
GetPreviousRow
Reads the previous row into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate
Updates a single value in the current row. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
UpdateCurrentRow (values() AsObject)
Update the current row with the provided values. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
The JackcessDatabase object represents an Access database. Once opened the tables in the database may be passed to the Initialize method of a JackcessTable object.
Returns a reference to any available table in this access database, including system tables. Warning, this method is not designed for common use, only for the occassional time when access to a system table is necessary.
GetSystemTableNamesAsString()
Returns a String array containing the names of all the system tables in the database.
Initialises this object with a database index provided by JackcessTable.GetIndex.
IsForeignKeyAsBoolean
Returns true if the index is a foreign key. i.e. it is a field in the table that is a primary key in another table
IsPrimaryKeyAsBoolean
Returns True if the index is a primary key. i.e. it is a field whose values uniquely identify each record in that table
IsUniqueAsBoolean
Returns True if the index entries must be unique values. Some notes about uniqueness: Access does not seem to consider multiple null entries invalid for a unique index. Text indexes collapse case, and Access seems to compare only the index entry bytes, therefore two strings which differ only in case will violate the unique constraint.
Delete the current row. Throws IllegalStateException if the current row is not valid (at beginning or end of table), or already deleted
FindClosestRowByEntry (entryvalues() AsObject)
Moves to the first row (as defined by the cursor) where the index entries are >= the given values. If an exception is thrown, the cursor is restored to its previous state.
entryValues is an array with the column values for the index's columns.
Moves to the first row (as defined by the cursor) where the given column has the given value. If a match is not found (or an exception is thrown), the cursor is restored to its previous state. Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).
Moves to the first row (as defined by the cursor) where the index entries match the given values. If a match is not found (or an exception is thrown), the cursor is restored to its previous state. Warning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches). If the entry is found the row is read into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate entryValues is an array with the column values for the index's columns.
Moves to the next row (as defined by the cursor) where the given column has the given value. If a match is not found (or an exception is thrown), the cursor is restored to its previous state.
GetColumnValue (columnnameAsString) AsObject
Most Access data types map to types directly supported by Basic4android and can be returned as is. Only dates need special treatment to turn them into ticks for the Basic4android DateTime object. Rather than put a check for a Date in every call to this method it is incumbent on the programmer to pass the Date object to the JackcessDatabase.DateToTicks helper method.
Reads the next row into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate
GetPreviousRow
Reads the previous row into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate
Initialises this object with a table provided by JackcessDatabase.GetTable or JackcessTable.GetTable and a database index provided by JackcessTable.GetIndex or JackcessIndex.GetIndex.
IsAfterLastAsBoolean
Returns true if the cursor is currently positioned after the last row, false otherwise
IsBeforeFirstAsBoolean
Returns true if the cursor is currently positioned before the first row, false otherwise.
Reset
After calling this method, GetNextRow will return the first row in the table,
Updates a single value in the current row. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
UpdateCurrentRow (values() AsObject)
Update the current row with the provided values. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
Adds a single row to this table and writes it to disk. The values are expected to be given in the order that the Columns are listed by getColumns() method. values are the row values for a single row. The given row array will be modified if this table contains an auto-number column, otherwise it will not be modified. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
AddRows (valuesAsjava.util.List)
Add multiple rows to this table, only writing to disk after all rows have been written, and every time a data page is filled. This is much more efficient than calling addRow multiple times. Note, if this table has an auto-number column, the values written will be put back into the given row arrays. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
DeleteCurrentRow
Delete the current row (retrieved by a call to GetNextRow).
DetailsAsString
Returns a string containing potentially useful details of the Table.
DisplayAsString
Returns a string representation of the entire table in tab-delimited format.
GetColumnDataTypesAsString()
Returns the Access data type of each of the columns in the table as a String array.
GetColumnJavaTypesAsString()
Returns the Java data type of each of the columns in the table as a String array. Note that the Date type needs special treatment when read from the database. There are two helper methods, DateToTicks and DatefromTicks in JackcessDatabase to amp database Date type values to and from ticks for use in Basic4android. Access types map to Java types as follows.
BINARY: Byte[] of max length 255 bytes BOOLEAN: Boolean BYTE: Byte COMPLEX_TYPE: Integer - an autonumber field which is the key for a secondary table which holds the data DOUBLE: Double FLOAT: Float GUID: String with the pattern {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} INT: Short LONG: Integer MEMO: String of max length 8388607 chars MONEY: BigDecimal with at most 4 decimal places. NUMERIC: BigDecimal OLE: Byte[] of max length 16777215 bytes. SHORT_DATE_TIME: Date - basic4android does not directly support this type TEXT: String of max length 255 chars
GetColumnNamesAsString()
Returns the names of each of the columns in the table as a String array.
GetColumnValue (columnnameAsString) AsObject
Most Access data types map to types directly supported by Basic4android and can be returned as is. Only dates need special treatment to turn them into ticks for the Basic4android DateTime object. Rather than put a check for a Date in every call to this method it is incumbent on the programmer to pass the Date object to the JackcessDatabase.DateToTicks helper method.
Returns an Index for the table for use in JackcessIndex.Initialize.
GetIndexNamesAsString()
Returns the names of each of the indexes in the table as a String array.
GetNextRow
Reads the next row into an internal Map containing a set of Column name (String) and value (Object) pairs. The values of individual columns in the row may be obtained by GetColumnValue or GetColumnValueAndDate
Initialises this object with a database table provided by JackcessDatabase,GetTable.
Reset
After calling this method, GetNextRow will return the first row in the table,
UpdateCurrentRow (values() AsObject)
Update the current row with the provided values. Any Date values should be passed as ticks to the Jackcess.DateFromTicks helper method and the returned Date object used here.
Note the after invoking this method GetColumnValue will return the old values not the new ones. This is unlike the behaviour of Cursor.UpdateCurrentRow and Cursor.SetCurrentRowValue after which the new values ARE available. The reason for this is that Cursor rereads the current row to update its stored values but a Table cannot do this as it lacks the necessary method.
Top