---
title: "The database is already in use by another process"
author: "nbaertuo"
date: "2010-06-16T15:47:11Z"
tags: []
categories: ["企业架构"]
slug: "the-database-is-already-in-use-by-another-process"
draft: false
lastmod: "2010-06-16T15:47:11Z"
id: 692564
url: "https://nbaertuo.iteye.com/blog/692564"
---

java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@afdb14ea\[file =D:\\db\\human.lck, exists=true, locked=false, valid=false, fl =null]: java.lang.Exception:  另一个程序已锁定文件的一部分，进程无法访问。 : D:\\db\\human.lck

原写法：

def sql = Sql.newInstance("jdbc:hsqldb:file:d:/db/human ;ifexists=true", "sa",  
                  "", "org.hsqldb.jdbcDriver")

 

正确写法：

def sql = Sql.newInstance("jdbc:hsqldb:hsql://localhost/xdb ;ifexists=true", "sa",  
                  "", "org.hsqldb.jdbcDriver")