Persistency Configuration Files

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: When persisting into a relational database, GigaSpaces uses two configuration files: type.properties and jdbc.properties.

This page is specific to:
GigaSpaces 5.x

If you're interested in another version, click it below:
GigaSpaces 6.0
[GigaSpaces 6.5]

Overview

When persisting into a relational database, GigaSpaces uses two configuration files:

  • The type.properties file includes the Java-to-SQL mapping definition. This information is essential, since various RDBMS have different internal names for column-types, and this information is not always available dynamically from their metadata.
  • The jdbc.properties file includes information about the driver class, URL, and authentication information that the JDBC driver uses to connect to the RDBMS.
The location of the JDBC SA configuration files should be defined when creating a persistent space. GigaSpaces distribution includes configurations 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:

<StorageAdapterURL>/GenericJDBCProperties/HSQLProperties</StorageAdapterURL>

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 may place the JDBC SA configuration files at your prefered location. You should make sure the relevant folder is part of the space JVM classpath or application classpath when running in embedded space mode.

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 may 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.

Persisting Binary Fields

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.

Example 

You may download hsqlpersistent-space-schema.xml schema to be used as part of this example. This file should be copied into <GigaSpaces Root>\config\schemas.

The HSQL database jdbc.properties file:

driverClass=org.hsqldb.jdbcDriver
#embedded mode
connectionUrl=jdbc:hsqldb:testDB
#remote mode
#connectionUrl=jdbc:hsqldb:hsql://localhost
username= sa
password=
The name and location of the HSQL database files determined by the jdbc.properties.
In this case the HSQL database files created at <GigaSpaces ROOT\bin folder and named testDB.*.
Property Description
driverClass The JDBC driver class – org.hsqldb.jdbcDriver. This class is located in the hsqldb.jar file in the <GigaSpaces ROOT>/lib/jdbc directory. The jar file is already included in the GigaSpaces classpath, so there is no need to add it manually.
connectionUrl The connectionUrl is the URL used by the JDBC driver to establish a connection to the database. You may replace the testDB with your own database name.
username Database user username.
password Database user password.

The HSQL database types.properties file:

java.lang.String=VARCHAR(3000)
java.lang.Boolean=
java.lang.Byte=
java.lang.Short=
java.lang.Integer=
java.lang.Long=
java.lang.Float=
java.lang.Double=
java.lang.Character=
binary=VARBINARY
longBinary=LONGVARBINARY

The space schema should include the following as part of the <persistent> options:

<persistent>
   <enabled>true</enabled>
   <StorageAdapterClass>com.j_spaces.sadapter.GenericJDBC.JDBCStorageAdapter</StorageAdapterClass>
   <AdapterType />
   <CacheLoaderClass />
   <DataBaseName>${com.gs.home}/GenericJDBCProperties/HSQLProperties/mydb</DataBaseName>
  <userName />
  <password />
  <Number_Sync_Objects>100</Number_Sync_Objects>
  <Check_Point_Period>1000</Check_Point_Period>
  <Page_Pool_Size>32768</Page_Pool_Size>
  <Sync_On_Commit>true</Sync_On_Commit>
  <StorageAdapterURL>/GenericJDBCProperties/HSQLProperties</StorageAdapterURL>
  <force-cold-init>false</force-cold-init>
  </persistent>

To start the persistent space use:

gsServer "/./hsqlspace?schema=hsqlpersistent"

The mappings for wrapper classes (Boolean, Byte, etc.) are determined from the driver's metadata during runtime. Strings and longBinary data are mapped explicitly.
GigaSpaces maps native Java types into their relevant SQL types. Arrays, Collections, and user-defined class type attributes are serialized and stored as a blob inside a relevant row cell. If your Entry holds large arrays or collection attributes, make sure your types.properties includes sufficient size for a blob SQL type.
The database table that stores Entry data is generated when the first instance of a specific class is written to the space. A Javaspace.snapshot call also generates a relevant empty table.
The database tables generated by GigaSpaces are deleted when cleaning the space. This can be done by calling the IJSpace.clean API , running the cleanSpace command line, or by running the clean space option in the Space Browser.


Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels

 
(None)