Version 3

    JBossCache: JDBC-based CacheLoader

     

    JDBC-based implementation of

    org.jboss.cache.loader.CacheLoader

    is in

    org.jboss.cache.loader.JDBCCacheLoader

    class.

    The implementation uses one table. Each row in the table represents one node. There are three columns in the table:

    • column for Fqn (which is also a primary key)

    • column for node's content (attribute/value pairs)

    • column for parent Fqn

     

    Fqn's are stored as strings. Node's content is stored as a BLOB.

     

    WARN: TreeCache does not impose any limitations on types of objects used in Fqn. But this implementation of CacheLoader requires Fqn to contain only objects of type

    java.lang.String

    . Another limitation for Fqn is its length. Since Fqn is a primary key, the default column type for it is

    VARCHAR

    which can store text values up to some maximum length determined by a database.

     

    Configuration

     

    Table Configuration

     

    Table and column names as well as column types are configurable with the following properties

     

    Property name

    Default value

    Description

    cache.jdbc.table.name

    jbosscache

    Table name.

    cache.jdbc.table.create

    true

    Is true or false. Indicates whether to create table at start phase. If true, the table is created if it does not already exist.

    cache.jdbc.table.drop

    false

    Is true or false. Indicates whether to drop the table at stop phase.

    cache.jdbc.fqn.column

    fqn

    Fqn column name.

    cache.jdbc.fqn.type

    varchar(255)

    Fqn column type

    cache.jdbc.node.column

    node

    Column name for node's content (attribute/value pairs).

    cache.jdbc.node.type

    blob

    Column type for node's content (attribute/value pairs).

    cache.jdbc.parent.column

    parent

    Parent fqn column.

     

    DataSource

     

    Property name

    Default value

    Description

    cache.jdbc.datasource

    java:/DefaultDS

    JNDI name of the DataSource to use

     

    JDBC driver properties

     

    The following properties must be specified if you are not using DataSource.

     

    Property name

    Description

    cache.jdbc.driver

    Fully qualified JDBC driver name

    cache.jdbc.url

    URL to connect to the database

    cache.jdbc.user

    User name to connect to the database

    cache.jdbc.password

    Password to connect to the database

     

    Configuration examples

     

    ##
    # JBoss Cache table properties
    cache.jdbc.table.name=JBossCache
    cache.jdbc.table.create=true
    cache.jdbc.table.drop=true
    cache.jdbc.fqn.column=FQN
    cache.jdbc.fqn.type=VARCHAR(255)
    cache.jdbc.node.column=NODE
    cache.jdbc.node.type=BLOB
    cache.jdbc.parent.column=PARENT
    
    ##
    # DataSource
    cache.jdbc.datasource=java:/DefaultDS
    
    ##
    # JDBC driver specific properties
    
    ## MySql
    cache.jdbc.driver=com.mysql.jdbc.Driver
    cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
    cache.jdbc.user=root
    cache.jdbc.password=
    
    ## Oracle
    cache.jdbc.driver=oracle.jdbc.OracleDriver
    cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
    cache.jdbc.user=jboss
    cache.jdbc.password=sa
    
    ## MS Sql Server
    cache.jdbc.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
    cache.jdbc.url=jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=jbossdb;SelectMethod=cursor
    cache.jdbc.user=sa
    cache.jdbc.password=
    cache.jdbc.node.type=image
    
    ## Pointbase
    cache.jdbc.driver=com.pointbase.jdbc.jdbcUniversalDriver
    cache.jdbc.url=jdbc:pointbase:server://localhost:9092/jboss,new
    cache.jdbc.user=PBPUBLIC
    cache.jdbc.password=PBPUBLIC