hsqldb简单使用总结
java -cp hsqldb.jar org.hsqldb.Server -database.0 ./db/test -dbname.0 test
java -cp hsqldb.jar org.hsqldb.util.DatabaseManagerSwing

由于我们是以Server模式启动的,需要选择HSQL Database Engine Server模式启动:


- 在容器初始化是得到通知,并获得上下文初始化对象,并启动hsqldb数据库;
- 容器销毁时,新建hsqldb连接,关闭hsqldb数据库;
public class HsqlDbListener implements ServletContextListener {
private static final Logger LOG = Logger.getLogger(HsqlDbListener.class);
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
LOG.info("start hsql db server...");
startServer();
}
/**
* java -cp hsqldb.jar org.hsqldb.Server -database.0 testdb -dbname.0 test
*/
private void startServer() {
Server server = new Server();
server.setDatabaseName(0, "test");
server.setDatabasePath(0, "/Users/mazhiqiang/develop/server/hsqldb-2.3.2/hsqldb/lib/testdb");
server.setPort(9002);
server.setSilent(true);
server.setTrace(true);
server.start();
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
try {
stopServer();
} catch (BusinessException e) {
throw new BusinessRuntimeException(e);
}
LOG.info("hsql db server stopped.");
}
private void stopServer() throws BusinessException {
Connection connection = null;
try {
Class.forName("org.hsqldb.jdbcDriver");
connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/test");
Statement statement = connection.createStatement();
statement.execute("SHUTDOWN;");
} catch (ClassNotFoundException e) {
throw new BusinessException(e);
} catch (SQLException e) {
throw new BusinessException(e);
}
}
<listener>
<listener-class>xxx.HsqldbListener</listener-class>
</listener>
hsqldb简单使用总结的更多相关文章
- Spring JdbcTemplate
参考链接: https://my.oschina.net/u/437232/blog/279530 http://jinnianshilongnian.iteye.com/blog/1423897 J ...
- Spring JdbcTemplate 方法详解
JdbcTemplate主要提供以下五类方法: execute方法:可以用于执行任何SQL语句,一般用于执行DDL语句: update方法及batchUpdate方法:update方法用于执行新增.修 ...
- (转)Spring JdbcTemplate 方法详解
Spring JdbcTemplate方法详解 文章来源:http://blog.csdn.net/dyllove98/article/details/7772463 JdbcTemplate主要提供 ...
- Spring JdbcTemplate方法详解
JdbcTemplate主要提供以下五类方法: execute方法:可以用于执行任何SQL语句,一般用于执行DDL语句: update方法及batchUpdate方法:update方法用于执行新增.修 ...
- JdbcTemplate主要提供以下五类方法:
execute方法:可以用于执行任何SQL语句,一般用于执行DDL语句: update方法及batchUpdate方法:update方法用于执行新增.修改.删除等语句:batchUpdate方法用于执 ...
- JdbcTemplate的主要用法
JdbcTemplate主要提供以下五类方法: execute方法:可以用于执行任何SQL语句,一般用于执行DDL语句: update方法及batchUpdate方法:update方法用于执行新增.修 ...
- 开涛spring3(7.2) - 对JDBC的支持 之 7.2 JDBC模板类
7.2 JDBC模板类 7.2.1 概述 Spring JDBC抽象框架core包提供了JDBC模板类,其中JdbcTemplate是core包的核心类,所以其他模板类都是基于它封装完成的,JDB ...
- jdbcTemplete(转)
文章来源:http://blog.csdn.net/dyllove98/article/details/7772463 JdbcTemplate主要提供以下五类方法: execute方法:可以用于执行 ...
- (转)JDBC模板类。
Spring JDBC抽象框架core包提供了JDBC模板类,其中JdbcTemplate是core包的核心类,所以其他模板类都是基于它封装完成的,JDBC模板类是第一种工作模式. JdbcTempl ...
随机推荐
- Axure RP 7.0 注册码
2016.01.25安装可用 Axure RP 7.0 注册码 用户名:axureuser 序列号:8wFfIX7a8hHq6yAy6T8zCz5R0NBKeVxo9IKu+kgKh79FL6 ...
- sar工具使用详细介绍
一:命令介绍:参考资料:http://linux.die.net/man/1/sar sar(System ActivityReporter系统活动情况报告)是目前Linux上最为全面的系统性能分析工 ...
- React-Native进阶_1.抽取样式和组件
组织应用的样式和组件 就像抽取工具类一样,放在单独的文件中,在要使用的地方去导入调用即可. 1.导出样式 Style 样式可以单独写在一个JavaScript文件中,然后导出给其他JavaScript ...
- 使用strdup 和 _strdup
在重构旧的C代码里,使用了这个函数, pNew = new OBJECTDESC; sscanf(buf, "%x", &i); pNew->wObjectID = ...
- HDU 3378
http://acm.hdu.edu.cn/showproblem.php?pid=3378 规则去玩三国杀就理解了 纯模拟 注意的点:有已经分出胜负但还在杀的情况出现,所以要每次杀操作前判断是否分出 ...
- ExtJS小技巧
一.从form中获取field的三个方法: 1.Ext.getCmp('id'); 2.FormPanel.getForm().findField('id/name'); 3.Ext.get('id/ ...
- 读文件名,shell
参考文献:(忘了哪个笔记了)http://www.docin.com/p-871820919.html
- vuex(二)getters
getters: 有时候,我们需要对state的数据进行筛选,过滤.这些操作都是在组件的计算属性进行的.如果多个组件需要用到筛选后的数据,那我们就必须到处重复写该计算属性函数:或者将其提取到一个公共的 ...
- ajax完成团队信息异步添加【实际项目】
第一:ajax往后台传参如何串(目前理解是json数组直接传给对象) 第二:ajax返回的数值通过PrintWriter.print方法返回 [参考前台页面关于团队信息是如何实现的] 参考页面user ...
- [Luogu4233]射命丸文的笔记
luogu description 对于\(x\in[1,n]\)求\(x\)点强联通竞赛图中的哈密顿回路的期望个数膜\(998244353\). \(n\le10^5\) sol 首先\(n\)点竞 ...