When persisting into a relational database with the JDBC SA, GigaSpaces uses two configuration files:
GigaSpaces queries the JDBC driver in runtime for type-mapping information. Each JDBC Driver may have different Java to SQL mapping.
In some cases, you can override these default setting to optimize the database storage mode.
To override the default JDBC mapping, you can assign values in the types.properties file. In many cases, there are a number of options to map a type (for example, binary type). You should consult the RDBMS manuals and choose the optimal type.
The location of the JDBC SA configuration files should be defined when creating a persistent space. GigaSpaces distribution includes configuration files for all major RDBMS vendors. These are located at the <GigaSpaces Root>\GenericJDBCProperties folder.
To make sure GigaSpaces uses the pre-defined configuration file, make sure the space schema file you are using includes the following:
The space instance searches for these files via a resource bundle search mechanism - i.e. you should make sure <GigaSpaces Root> is part of the GigaSpaces space JVM classpath.
You can place the JDBC SA configuration files at your preferred location. You should make sure the relevant folder is part of the space JVM classpath or application classpath when running in embedded space mode.
When starting two or more persistent spaces on the same machine with an embedded database (like HSQL), you might need to override the GS_INSTALL_DIR or GenericJDBCProperties, otherwise all spaces can load the same GenericJDBCProperties/HSQLProperties/jdbc.properties files, which can result in failure when creating the database.
Using the SpaceFinder properties object, you can override the connectionUrl property, override the username and password, or any other jdbc.properties property in runtime:
Any field that its type is not a simple type (e.g custom Java objects, arrays) is persisted as a binary field. The type of this field is defined using the binary property in the types.properties file.
For example: binary=LONG means that a LONG database type is used for binary fields.
The longBinary property is intended for persisting internal space tables. Make sure you do not confuse this property with the binary property described above.
Persisting large objects is done using BLOBS (Binary Large OBjects). For more details, refer to the Persisting Large Entries section.
You can download the hsqlpersistent-space-schema.xml schema to be used as part of this example. This file should be copied into <GigaSpaces Root>\config\schemas.
If you are using GigaSpaces version 6.0.1 and onwards, remove the min_connections, max_connections, and port elements from the schema, since they are not used in this version.
The HSQL database jdbc.properties file:
The name and location of the HSQL database files is determined by the jdbc.properties file. In this case the HSQL database files are created in the <GigaSpaces Root\bin folder and named testDB.*.
You can override properties in the jdbc.properties file using the SpaceFinder, see above.
The HSQL database types.properties file:
The space schema should include the following as part of the <persistent> options:
It is possible to use a different adapter according to your database. To do this, in the <DataBaseName> tag, specify an adapter instead of HSQLProperties. The following adapters are available under <GigaSpaces Root>\GenericJDBCProperties:
All of the schema elements above can be overridden using a custom properties file. For more details, see: Overriding Default Configuration.
To start a persistent space use:
The mappings for wrapper classes (Boolean, Byte, etc.) are determined from the driver's metadata during runtime. Strings and longBinary data are mapped explicitly.