2007-04-09
在应用服务器下启动HSQL数据库
关键字: 总结说明:
在应用服务器(tomcat,jboss,weblogic)启动的时候,启动HSQL数据库。
步骤:
1。在web.xml下配置监听器
xml 代码
- <listener>
- <listener-class>
- com.emap.mds.db.RunHSQLListener
- listener-class>
- listener>
注意:这个监听器必须配置在spring和其他监听器的前面(在web.xml的顺序)。
2.编写监听器
java 代码
- public class RunHSQLListener implements ServletContextListener
- {
- /**
- * Initialize the root web application context.
- */
- public void contextInitialized( ServletContextEvent event)
- {
- ServletContext context = event.getServletContext();
- context.log("开始启动HSQL数据库..");
- org.hsqldb.Server.main(new String[] { "-database.0",
- context.getRealPath("/WEB-INF/db/mds"), "-dbname.0", "mds" });
- context.log("成功启动HSQL数据库");
- }
- /**
- * Create the ContextLoader to use. Can be overridden in subclasses.
- *
- * @return the new ContextLoader
- */
- protected ContextLoader createContextLoader()
- {
- return new ContextLoader();
- }
- /**
- * Close the root web application context.
- */
- public void contextDestroyed( ServletContextEvent event)
- {
- }
- }
注意:hsql数据库放在WEB-INF的db文件夹下,cms是数据库名称,别名是cms。
- 浏览: 79801 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
J2EE开发注意事项
写绝对路径,在移动文件到其他文件夹的时候,不需要修改代码。
-- by fantasy -
J2EE开发注意事项
5.页面上的地址原则上写绝对路径。 是何道理呢? 相对路径先定位到根,然后定 ...
-- by nwangwei -
深入osworkflow的function
kathytingzi 写道怎么实现会签阿,谢谢啦 增加两个conditon, ...
-- by fantasy -
使用Filter控制页面的权限
恩,是面向切面。过滤器可以看成是一个切面。
-- by fantasy -
深入osworkflow的function
工作流初学者: 参考:http://hi.baidu.com/vjame/blo ...
-- by amuj2ee






评论排行榜