主要環境:
JBOSS 5.1.0
Orace 10G
Gatein3.1.0-GA
引用一下Gatein 官方使用手冊上的原文並簡單反譯和註解一下大概意思:
2.1. Database Configuration
2.1.1. Overview
GateIn 3.1 has two different database dependencies. One is the identity service configuration, which depends on Hibernate. The other is Java content repository (JCR) service, which depends on JDBC API, and can integrate with any existing datasource implementation.
When you change the database configuration for the first time, GateIn will automatically generate the proper schema (assuming that the database user has the appropriate permissions).
GateIn 3.1 assumes the default encoding for your database is latin1. You may need to change this parameter for your database in order for GateIn 3.1 to work properly.
概述: 主要是說Gatein依賴兩個資料庫 一個是用來做身份認證的,是用Hibernate的。 另一個用來支援JCR的,用JDBC API 兩個都可以支援當前任何已存在的數庫。 在你第一次改變資料庫配置後,Gatein將會自動的產生schema(註解:資料庫的方案,就是表,視圖等)(你的資料庫使用者要有這些許可權) GateIn3.1假定你的資料庫編碼方式為latin1,你可能需要改變你的資料庫的編碼方式來讓Gate3.1正常工作 (註解:latin1 就是ISO8859-1編碼,這個好像是mySql常用的編碼方式,在我建立Oracle資料庫時並沒有這個編碼方式,我用的是UTF-8,這個是寬字元集,應該是相容的,反正到現在還沒發現有問題)2.1.2. Configuring the database for JCR
To configure the database used by JCR you will need to edit the file:
$JBOSS_HOME/server/default/conf/gatein/configuration.propertiesFor Tomcat, the file is located at
$TOMCAT_HOME/gatein/conf/configuration.propertiesAnd edit the values of driver, url, username and password with the values for your JDBC connection (please, refer to your database JDBC driver documentation).
gatein.jcr.datasource.driver=org.hsqldb.jdbcDriver
gatein.jcr.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcjcr_${name}
gatein.jcr.datasource.username=sa
gatein.jcr.datasource.password=
By default, the name of the database is "jdbcjcr_${name}" - ${name} should be a part of the database name, as it is dynamically replaced by the name of the portal container extension (for instance, gatein-sample-portal.ear defines "sample-portal" as container name and the default portal defines "portal" as container name).
In the case of HSQL the databases are created automatically. For any other database you will need to create a database named jdbcjcr_portal (and "jdbcjcr_sample-portal" if you have gatein-sample-portal.ear in $JBOSS_HOME/server/default/deploy - note that some databases don't accept '-' in the database name, so you may have to remove $JBOSS_HOME/server/default/deploy/gatein-sample-portal.ear)
Make sure the user has rights to create tables on jdbcjcr_portal, and to update them as they will be automatically created during the first startup .
Also add your database's JDBC driver into the classpath - you can put it in $JBOSS_HOME/server/default/lib (or $TOMCAT_HOME/lib, if you are running on Tomcat)
MySQL example:
Let's configure our JCR to store data in MySQL. Let's pretend we have a user named "gateinuser" with a password "gateinpassword". We would create a database "mygateindb_portal" (remember that _portal is required), and assign our user the rights to create tables.
Then we need to add MySQL's JDBC driver to the classpath, and finally edit gatein.ear/02portal.war/WEB-INF/conf/jcr/jcr-configuration to contain the following:
gatein.jcr.datasource.driver=com.mysql.jdbc.Driver
gatein.jcr.datasource.url=jdbc:mysql://localhost:3306/mygateindb${container.name.suffix}
gatein.jcr.datasource.username=gateinuser
gatein.jcr.datasource.password=gateinpassword
2.1.2. JCR的資料庫配置修改設定檔: JBOSS: $JBOSS_HOME/server/default/conf/gatein/configuration.propertiesTomcat:$TOMCAT_HOME/gatein/conf/configuration.properties修改其中的驅動,url,使用者名稱,密碼,例如:gatein.jcr.datasource.driver=org.hsqldb.jdbcDriver
gatein.jcr.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcjcr_${name}
gatein.jcr.datasource.username=sa
gatein.jcr.datasource.password=
....略去說它自已的預設配置方式,重點在下一段裡.....
說在資料庫為HSQL時,Gatein會自動的建立資料庫,但是如果是別的那麼要手動的建立名為:"jdbcjcr_portal"的資料庫
(註解:根據上一段所說,應該是庫名必須為_portal結尾,但是保險起見,我把我oracle的全域資料庫名建立為,jdbcjcr_portal,
為這我還重裝了一次oracle,不知道如果不改而只是建立一個名為jdbcjcr_portal的schema可以不可以,知道的試下告訴我一下吧)
(還要建立一個名為"jdbcjcr_sample-portal"的資料庫,為GateIn的一個例子使用,但是有些資料庫不支援"-"命名資料庫,
那麼就把這個例子刪除,位置是$JBOSS_HOME/server/default/deploy/gatein-sample-portal.ear)
(註解:我是直接幹掉了這個ear的,簡單方便)
要確保你的資料庫使用者有建表的許可權。要把你的資料庫驅動考到$JBOSS_HOME/server/default/lib (你用Tomcat的話是$TOMCAT_HOME/lib)給出了一個mysql 的例子:gatein.jcr.datasource.driver=com.mysql.jdbc.Driver
gatein.jcr.datasource.url=jdbc:mysql://localhost:3306/mygateindb${container.name.suffix}
gatein.jcr.datasource.username=gateinuser
gatein.jcr.datasource.password=gateinpassword
我的
gatein.jcr.config.type=local
gatein.jcr.datasource.name=java:jdbcjcr
gatein.jcr.datasource.dialect=auto
gatein.jcr.datasource.driver=oracle.jdbc.driver.OracleDriver
gatein.jcr.datasource.url=jdbc:oracle:thin:@192.168.0.200:1521:dgoral
gatein.jcr.datasource.username=jdbcjcr_portal
gatein.jcr.datasource.password=XXXX
2.1.3. Configuring the database for the default identity store
By default, users are stored in a database. To change the database in which to store users, you will need to edit the file:
$JBOSS_HOME/server/default/conf/gatein/configuration.propertiesFor Tomcat, the file is located at
$TOMCAT_HOME/gatein/conf/configuration.propertiesYou will find the same kind of configuration as in jcr-configuration.xml:
gatein.idm.datasource.driver=org.hsqldb.jdbcDriver
gatein.idm.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcidm_${name}
gatein.idm.datasource.username=sa
gatein.idm.datasource.password2.1.3. 配置身份認證的資料庫還是上面的那個設定檔:JBOSS: $JBOSS_HOME/server/default/conf/gatein/configuration.propertiesTomcat:$TOMCAT_HOME/gatein/conf/configuration.properties例子:(註解:這個我和上面那個用的同一個庫,粘帖下就行了)gatein.idm.datasource.driver=org.hsqldb.jdbcDriver
gatein.idm.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcidm_${name}
gatein.idm.datasource.username=sa
gatein.idm.datasource.password
我的
# IDM
gatein.idm.datasource.name=java:jdbcidm
gatein.idm.datasource.driver=oracle.jdbc.driver.OracleDriver
gatein.idm.datasource.url=jdbc:oracle:thin:@192.168.0.200:1521:dgoral
gatein.idm.datasource.username=jdbcjcr_porta
gatein.idm.datasource.password=XXXX
看完上面的也就基本可以弄好了。多說一點,我對Oracle不是很瞭解,oracle的sid是不可以有“_“的,但是全域資料庫名可以有,但是串連url中的部分還是要寫sid的,寫資料庫名是不行了,有瞭解oracle的請指點一下。