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 ...
随机推荐
- asp.net string有多行文字
用如下格式设置
- FFmpeg再学习 -- 硬件加速编解码
为了搞硬件加速编解码,用了一周时间来看 CUDA,接下来开始加以总结. 一.什么是 CUDA (1)首先需要了解一下,什么是 CUDA. 参看:百度百科 -- CUDA 参看:CUDA基础介绍 参看: ...
- table中文字过长使用省略号
1.设置table固定布局,否则自适应布局会不受控制 table{ table-layout: fixed; } 2.设定td宽度占比 <table> <col width=&quo ...
- UWP 流畅设计中的光照效果(容易的 RevealBorderBrush 和不那么容易的 RevealBackgroundBrush)
在 Windows 10.0.16299 中,RevealBrush 被引入,可以实现炫酷的鼠标滑过高亮效果和点击光照.本文将告诉大家如何完整地实现这样的效果. Reveal 的效果(自带) 在微软官 ...
- 再也不用克隆多个仓库啦!git worktree 一个 git 仓库可以连接多个工作目录
我在 feature 分支开发得多些,但总时不时被高优先级的 BUG 打断需要临时去 develop 分一个分支出来解 BUG.git 2.6 以上开始提供了 worktree 功能,可以解决这样的问 ...
- vs2010中配置OpenGL以及针对64位系统所遇问题的解决办法
一.下面将对VS2010中配置OpenGL进行简单介绍. 学习OpenGL前的准备工作 第一步,选择一个编译环境 现在Windows系统的主流编译环境有Visual Studio,Broland C+ ...
- Ecel 粘贴图片并调整大小,移到底层
Sub Click() ActiveSheet.Pictures.Paste.Select Selection.ShapeRange.ScaleWidth 1.4, msoTrueSelection. ...
- 错误:Authentication with old password no longer supported, use 4.1 style passwords.
今天重新装了系统,mysql connector 使用了官网的最新版本(6.8.3). 启动项目出现标题中的错误.原因大家谷歌. 解决方法,使用低版本的 connector. 我使用的是 6.5.6 ...
- MySQL Geometry扩展在地理位置计算中的效率优势
由于在Geometry中,有相关自带函数和SPATIAL INDEX的性能优化,可以让某些位置计算的效率提升.以下是几种计算方法的效果对比. 1. 数据准备 首先创建一个数据表,这是一个店铺数据表,结 ...
- ffmpeg hls 点播负载均衡简单实现
备注: 主要是进行文件的切片处理,以及m3u8 的文件前缀添加以达到通过nginx 或者类似的分布式文件工具进行数据切片处理 参考配置如下: ffmpeg -y -i mydemo.mp4 -vcod ...