Summary: When persisting into a relational database using the JDBC SA, GigaSpaces uses two configuration files:
type.properties and
jdbc.properties.
OverviewWhen 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. JDBC SA Configuration File LocationThe 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: <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 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. Overriding GenericJDBCPropertiesWhen 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: /** Override /GenericJDBCProperties/HSQLProperties/jdbc.properties */ Properties prop = new Properties(); prop.setProperty("driverClass", "org.hsqldb.jdbcDriver"); prop.setProperty("connectionUrl", "jdbc:hsqldb:/home/igor/GigaSpacesXAP6.0/db-files/primarySpaceDB"); prop.setProperty("username", "igor"); prop.setProperty("password", "giga"); IJSpace space = (IJSpace)SpaceFinder.find("/./myHSQLSpace", prop); Persisting Binary FieldsAny 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.
ExampleYou 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.
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 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 /> <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 a persistent space use: gsInstance "/./hsqlspace?schema=persistent"
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.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |