This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. Introduction #
This page describes uing the H2 Database with Liferay.
Environment #
- Tomcat5.5.27
- Portal trunk (revision 34653)
Steps #
Download h2 database #
- http://www.h2database.com
Put h2-x.x.x.jar file into classpath. #
Set jdbc properties in portal-ext.properties file. #
#
# 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=Apply patch #
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) {compile and deploy the patched portal-impl.jar.
Start tomcat #
You will see it's using h2 in tomcat console
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)
Related Links #
25334 Views