我们以tomcat5.5.27 和 portal trunk version 34830 举例.
下载H2数据库
官网http://www.h2database.com
将h2-x.x.x.jar放到tomcat/common/lib/ext
修改portal-ext.properties文件设置jdbc
#
# H2
#
jdbc.default.driverClassName=org.h2.Driver
jdbc.default.url=jdbc:h2:${liferay.home}/data/h2/lportal;DB_CLOSE_ON_EXIT=FALSE
jdbc.default.username=sa
jdbc.default.password=
打补丁
Index: portal-impl/src/com/liferay/portal/tools/sql/DBUtil.java
--- portal-impl/src/com/liferay/portal/tools/sql/DBUtil.java (revision 34653)
+++ portal-impl/src/com/liferay/portal/tools/sql/DBUtil.java Fri Jul 24 16:32:13 CST 2009
@@ -49,25 +49,7 @@
import javax.naming.NamingException;
public abstract class DBUtil {
@@ -77,6 +59,8 @@
public static final String TYPE_FIREBIRD = "firebird";
+ public static final String Type_H2 = "h2";
+
public static final String TYPE_HYPERSONIC = "hypersonic";
public static final String TYPE_INFORMIX = "informix";
@@ -100,7 +84,7 @@
public static final String TYPE_SYBASE = "sybase";
public static final String[] TYPE_ALL = {
- TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, TYPE_HYPERSONIC, TYPE_INFORMIX,
+ TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, Type_H2, TYPE_HYPERSONIC, TYPE_INFORMIX,
TYPE_INGRES, TYPE_INTERBASE, TYPE_JDATASTORE, TYPE_MYSQL, TYPE_ORACLE,
TYPE_POSTGRESQL, TYPE_SAP, TYPE_SQLSERVER, TYPE_SYBASE
};
@@ -137,7 +121,7 @@
else if (type.equals(TYPE_FIREBIRD)) {
dbUtil = FirebirdUtil.getInstance();
}
- else if (type.equals(TYPE_HYPERSONIC)) {
+ else if (type.equals(TYPE_HYPERSONIC) || type.equals(Type_H2)) {
dbUtil = HypersonicUtil.getInstance();
}
else if (type.equals(TYPE_INFORMIX)) {
@@ -187,7 +171,7 @@
_dbUtil = DB2Util.getInstance();
}
}
- else if (dialect instanceof HSQLDialect) {
+ else if (dialect instanceof HSQLDialect || dialect instanceof H2Dialect) {
_dbUtil = HypersonicUtil.getInstance();
}
else if (dialect instanceof InformixDialect) {
编译打包发布portal-impl.jar.
启动tomcat
应该就能看到Liferay在使用h2数据库
Loading file:/C:/Projects/lportal/bundles-trunk/tomcat-5.5.27/webapps/ROOT/WEB-INF/classes/portal-ext.properties
Loading file:/C:/Projects/lportal/bundles-trunk/tomcat-5.5.27/webapps/ROOT/WEB-INF/classes/portal-developer.properties
08:12:41,134 INFO [DialectDetector:58] Determining dialect for H2 1
08:12:42,603 INFO [DialectDetector:91] Using dialect org.hibernate.dialect.H2Dialect
Loading jar:file:/C:/Projects/lportal/bundles-trunk/tomcat-5.5.27/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/captcha.properties
08:13:29,551 INFO [PortalImpl:249] Portal lib directory /C:/Projects/lportal/bundles-trunk/tomcat-5.5.27/webapps/ROOT/WEB-INF/lib/
Starting Liferay Portal Standard Edition 5.3.0 (Bunyan / Build 5300 / May 18, 2009)
进展请看
http://issues.liferay.com/browse/LPS-4313
英文
http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/H2