class Experimental . PersistentDatabaseViaSQL {
string dataColType;
string flagColType;
string keyColType;
string pagerServiceName;
string persistentDBtableName;
oid sqlODBC;
string thisServiceName;
} inherits from Object;
The class PersistentDatabaseViaSQL implements storage of persistent objects using SQL commands on behalf of the PersistenceService. The interface to the database is maintained by an SQLviaODBC object. Only two methods are used, connectToDSN and performSQLcommand, which provides the opportunity for the PersistentDatabaseViaSQL gateway to be used with other relational database interfaces.
The persistent object data is stored in a table (whose name defaults to "PersistentObjects") comprised of 3 columns:
Ideally, the binary data would be stored as-is; unfortunately, expecting generic binary large object support is still just wishful thinking in the year 2002. By default, the binary information is transformed to plain text by converting it to a base64 representation, which yields a 3-to-4 expansion (which is much better than the 1-to-2 expansion which would result with a simple conversion to hexadecimal characters).
Problems discovered:
PersistentDatabaseViaSQL:create()
See initialize and initializeFromFile. If a single argument is passed, initializeFromFile is used; if multiple arguments are provided, then initialize is called.
PersistentDatabaseViaSQL:initializeFromFile(any paramFileArg)
The initializeFromFile method permits externalization of parameters using a ParseParameterFile object. The argument paramFileArg is passed as-is as the first argument to the create method.
The following attributes are extracted from the default section:
See connectToDSN for details on the 3 ODBC-related parameters. For Oracle, dataColType should be "LONG RAW" (VARCHAR is limited to 4000 characters).
The initialize method is invoked with appropriate arguments after the various configuration parameters have been retrieved from the ParseParameterFile object.
A value of 0 is returned on success; -1 indicate an error.
PersistentDatabaseViaSQL:initialize(string serviceName, string DSNname, string userName, string password, optional int32 createDB)
The serviceName argument determines the name by which the service will be registered and will need to correspond to an argument provided when a PersistenceService object is created.
The DSNname, userName and password arguments correspond to the critical three required to establish an ODBC-based connection to a database. A SQLviaODBC object is created to interface with the database and these three arguments are sent as the arguments for a connectToDSN method invocation.
If createDB is passed as 1, the necessary database table will be created before the initialization is complete. While not optimal, it is safe to always have this set because the attempt to re-create an existing table will be denied by the database and tolerated by this method.
A value of 0 is returned on success; -1 indicate an error.
PersistentDatabaseViaSQL:saveObject(string oidKey, string objData)
Saves the object record in the database.
PersistentDatabaseViaSQL:restoreObject(string oidKey)
Retrieves an object's state from the database.
PersistentDatabaseViaSQL:removeObject(string oidKey)
Deletes an object's state data from the database.
PersistentDatabaseViaSQL:listObjects()
Returns a list of all objects maintained by the database. Any temporary objects are automatically deleted from the database before the list is generated.
PersistentDatabaseViaSQL:stopService()
The stopService method requests termination and deletion of the storage service. It is normally used to request external processes to gracefully terminate and is provided here for compatibility.