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 ...
随机推荐
- 移动设备web开发插件iScroll的使用详解
地址:http://blog.nnnv.cn/index.php/archives/65
- iOS 阶段学习第六天笔记(数组)
iOS学习( ...
- IOS 的本地通知
IOS 的本地通知 - (void)viewDidLoad { [super viewDidLoad]; UILocalNotification* localNotification = [[UILo ...
- css工具类封装
温馨提示:一下css封装,建议按需使用,否则会造成很大的代码冗余,且很多样式会造成不符合预期的效果,建议合理使用 <a href="https://meyerweb.com/eric/ ...
- Ubuntu下使用openssl为apache2配置ssl
安装apache2 sudo apt-get install apache2 安装openssl 一般系统自带,可以通过openssl version查看,如果没有, sudo apt-get ins ...
- php实现彩票走势图组选图用颜色区分
找了好久都没有关于这个的东西,我也是一步一步从百度知道上问出思路来的 $xxx = $row['bai'] ; $yyy = $row['shi'] ; $zzz = $row['ge'] ; $zu ...
- hive表数据导出到csv乱码原因及解决方案
转载自http://blog.csdn.net/lgdlxc/article/details/42126225 Hive表中的数据使用hive - e"select * from table ...
- 几种设置UITableView的cell动态高度的方法
1.UITableView加载的顺序是先得到表的行的高度,也就是先调用heightForRowAtIndexPath方法,然后再调用cellForRowAtIndexPath,所以我们有两个办法实现自 ...
- 《DSP using MATLAB》示例Example 8.16
%% ------------------------------------------------------------------------ %% Output Info about thi ...
- Java面向对象设计主要有三大特征:封装性、继承性和多态性
Java面向对象设计主要有三大特征:封装性.继承性和多态性 一 封装性 1.1 概念:它是将类的一些敏感信息隐藏在类的类部,不让外界直接访问到,但是可以通过getter/setter方法间接访 ...