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 ...
随机推荐
- TI IPNC Web网页之网页修改教程
web网页程序修改 打开gStudio之后,点击菜单栏中Help->Contents.先把这个诡异的编程语言看一遍吧.这里搬一些东西出来. GoDB简介 从第一副图片中,我们可以看出,从源文件到 ...
- CUDA Samples: Dot Product
以下CUDA sample是分别用C++和CUDA实现的两个非常大的向量实现点积操作,并对其中使用到的CUDA函数进行了解说,各个文件内容如下: common.hpp: #ifndef FBC_CUD ...
- 使用微软T4 template进行代码生成
使得软件工程高效开发的主要方法是复用.复用的宗旨是提高设计的内聚性,主要包括:函数,类,模式,组件,框架等等.而有些应用场景并都是可以直接拿来现成代码使用的,有时代码库的代码不是那么容易修改,或者根本 ...
- iOS【野路子】精准获取webView内容高度,自适应高度
关于WebView内容高度的获取,相信很多人都踩过坑,无法获取到准确高度,导致页面布局出现差错,搜到的资料很多但都无法解决问题,以下是个人经验总结: 项目需求实现H5文章&原生评论效果,文章是 ...
- 解决TensorFlow最新代码编译错误问题
老是有个习惯,看到开源代码更新了,总是想更新到最新版,如果置之不理的话,就感觉自己懒惰了或有的不负责任了,这个也可能是一种形式的强迫症吧: 前几天晚上git pull TensorFlow,完事后也没 ...
- swift 数组作为函数参数的书写格式
数组定义 --[来自百度知道] Swift语言使用类型名紧接中括号[]来简化标准库中定义的命名型类型Array.例如 Array<String> = ["Alex", ...
- requestAnimationFrame 兼容不支持时的问题
(function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for (var x = 0; x < v ...
- BZOJ5059 前鬼后鬼的守护 【堆扩展】*
BZOJ5059 前鬼后鬼的守护 Description 八云紫的式神八云蓝有一张符卡名为[式神-前鬼后鬼的守护],这张符卡的弹幕为BOSS从两侧向自机发射大玉,大玉后面跟着一些小玉,形成一个&quo ...
- Codeforces 15E Triangles 【组合计数】
Codeforces 15E Triangles Last summer Peter was at his granny's in the country, when a wolf attacked ...
- 从数据库导出数据到excel之POI操作
项目说明: 1:数据库中有两张表,主键关联 2:根据条件查询数据 3:处理为需要的数据封装类型,然后传到导出excel的方法中 <--框架部署就不详谈了,用的spring框架--> 补充: ...