---
title: "启动H2数据库并导入数据库脚本"
author: "xyh"
date: "2010-08-23T08:48:45Z"
tags: []
categories: ["编程语言"]
slug: "h2"
draft: false
lastmod: "2010-08-24T01:59:00Z"
id: 744685
url: "https://xyh.iteye.com/blog/744685"
---

因工作上的需要，在生产环境使用到嵌入式数据库H2。
修改H2的源码，实现以下几点：
1.启动H2数据库不打开浏览器窗口（默认是打开的）
2.数据库创建SQL增加了支持BigDecimal类型，h2数据库默认是不支持bigdecimal类型的：

```sql
create table test(id int(11),charge BigDecimal(12))
```

3.通过传参数方式导入数据库脚本

```java

new Console().runTool();
new RunScript().runCustomTool("jdbc:h2:~/test", "sa","", "c:/schema.sql");

```