Java 无法从基础数据库获取连接!-HSQL数据库

Java 无法从基础数据库获取连接!-HSQL数据库,java,hibernate,orm,hsqldb,Java,Hibernate,Orm,Hsqldb,我正试图通过Gavin King的Hibernate从Java持久性学习Hibernate 我刚刚从这个位置下载了书中给出的例子 我使用ant startdb启动了我的HSQL数据库,数据库成功启动 当尝试运行目标schemaexport时,我得到以下错误 schemaexport:[hibernatetool] 使用 标准配置[hibernatetool] 1.任务:hbm2ddl(生成数据库模式)[hibernatetool]18:07:56555 信息环境:500-Hibernate 3.

我正试图通过Gavin King的Hibernate从Java持久性学习Hibernate

我刚刚从这个位置下载了书中给出的例子

我使用ant startdb启动了我的HSQL数据库,数据库成功启动

当尝试运行目标schemaexport时,我得到以下错误

schemaexport:[hibernatetool] 使用 标准配置[hibernatetool] 1.任务:hbm2ddl(生成数据库模式)[hibernatetool]18:07:56555 信息环境:500-Hibernate 3.2.0.cr5[hibernatetool]18:07:56555信息环境:533- hibernate.properties未找到 [hibernatetool]18:07:56555信息 环境:667-字节码提供程序 名称:cg lib[hibernatetool] 18:07:56571信息环境:584- 使用JDK1.4java.sql.Time戳 处理[hibernatetool]18:07:56617 信息配置:1384-配置 来自文件:h ibernate.cfg.xml [hibernatetool]18:07:56680信息 配置:507-读取映射 来自资源:hello/Message.hbm.xml [hibernatetool]18:07:56758信息 HbmBinder:300-映射类: 你好,留言 ->消息[hibernatetool]18:07:56851信息配置:1465 -配置的会话因子y:null[hibernatetool]18:07:56851信息 方言:141-使用方言: org.hibernate.di alect.hsql [hibernatetool]18:07:56914信息 SchemaExport:154-正在运行hbm2ddl 模式扩展端口[hibernatetool] 18:07:56914信息模式导出:174- 正在将生成的架构写入文件: C:\Users\Ramesh\Desktop\Tutorials\hibernate\hibernate 代码示例\jpwh- gettingstarted-070401\helloworld-native\helloworld-ddl.sql [hibernatetool]18:07:56914信息 SchemaExport:179-导出生成的 数据库模式[hibernatetool] 18:07:56914信息 C3P0ConnectionProvider:50-C3P0正在使用 驱动程序:org.hsqldb.jdbcDriver,URL: jdbc:hsqldb:hsql://localhost [hibernatetool]18:07:56914信息 C3P0ConnectionProvider:51-连接 属性:{user=sa}[hibernatetool] 18:07:56914信息 C3P0ConnectionProvider:54-自动提交 模式:false[hibernatetool] 18:08:26554警告 基本资源库:1222- com.mchange.v2.resource rcepool.BasicResourcePool$AcquireTask@61f1680f --获取尝试失败!!!清算未决收购。虽然 试图获得所需的新产品 资源,我们会取得更大的成功 超过允许的最大数量 获取尝试(30)。 [hibernatetool]18:08:26554错误 SchemaExport:202-模式导出 不成功

[hibernatetool]java.sql.SQLException: 无法从中获取连接 底层数据库! [冬眠醇]在 com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.j ava:104)[冬眠醇]at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che ckoutPooledConnection(C3P0PooledConnectionPool.java:236) [冬眠醇]在 com.mchange.v2.c3p0.PoolBackedDataSource.getConnectio n(PoolBackedDataSource.java:94) [冬眠醇]在 org.hibernate.connection.C3P0ConnectionProvider.getCo 连接(C3P0ConnectionProvider.java:35) [冬眠醇]在 org.hibernate.tool.hbm2ddl.ManagedProviderConnectionH prepare(ManagedProviderConnectionHelper.java:28) [冬眠醇]在 org.hibernate.tool.hbm2ddl.SchemaExport.execute(Schem aExport.java:180)[hibernatetool]
在 org.hibernate.tool.hbm2ddl.SchemaExport.create(Schema Export.java:133)[hibernatetool]
在 org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hb m2DDLExporterTask.java:55) [冬眠醇]在 org.hibernate.tool.ant.hibernateTooltTask.execute(Hibe rnateToolTask.java:171) [冬眠醇]在 org.apache.tools.ant.UnknowneElement.execute(UnknownEl ement.java:291)[hibernatetool]
在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机 方法[hibernatetool]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet hodAccessorImpl.java:39) [冬眠醇]在 sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg atingMethodAccessorImpl.java:25) [冬眠醇]在 java.lang.reflect.Method.invoke(Method.java:597) [冬眠醇]在 org.apache.tools.ant.dispatch.DispatchUtils.execute(D java:106)[hibernatetool] 在 org.apache.tools.ant.Task.perform(Task.java:348) [冬眠醇]在 org.apache.tools.ant.Target.execute(Target.java:390) [冬眠醇]在 org.apache.tools.ant.Target.performTasks(Target.java: 411)[冬眠醇]在 org.apache.tools.ant.Project.executeSortedTargets(Pro java:1397)[hibernatetool]
在 org.apache.tools.ant.Project.executeTarget(Project.ja 弗吉尼亚州:1366[冬眠醇]at org.apache.tools.ant.helper.DefaultExecutor.executeTa rgets(DefaultExecutor.java:41) [冬眠醇]在 org.apache.tools.ant.Project.executeTargets(Project.j ava:1249[hibernatetool]at org.apache.tools.ant.Main.runBuild(Main.java:801) [冬眠醇]在 org.apache.tools.ant.Main.startAnt(Main.java:218) [冬眠醇]在 org.apache.tools.ant.launch.Launcher.run(Launcher.jav a:280[冬眠醇]在 org.apache.tools.ant.launch.Launcher.main(Launcher.ja va:109)[冬眠醇]由以下原因引起: com.mchange.v2.resourcepool.cannotacquireResourceExchange 选项:资源池无法启动 从其主服务器获取资源 工厂或供应商。[冬眠醇]
在 com.mchange.v2.resourcepool.BasicResourcePool.awaitAc quire(BasicResourcePool.java:970) [冬眠醇]在 com.mchange.v2.resourcepool.BasicResourcePool.checkou tResource(BasicResourcePool.java:208) [冬眠醇]在 com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che ckoutPooledConnection(C3P0PooledConnectionPool.java:232) [冬眠醇]
<!-- Start the HSQL DB server -->
<target name="startdb" description="Run HSQL database server with clean DB">
    <!-- Delete database files -->
    <delete dir="${database.dir}"/>
    <java classname="org.hsqldb.Server"
          fork="yes"
          classpathref="project.classpath"
          failonerror="true">
        <arg value="-database.0"/>
        <arg value="file:${database.dir}/db"/>
    </java>
</target>
startdb:
     [delete] Deleting directory C:\Users\Ramesh\Desktop\Tutorials\hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\database
     [java] [Server@15ded0fd]: [Thread[main,5,main]]: checkRunning(false) entered
     [java] [Server@15ded0fd]: [Thread[main,5,main]]: checkRunning(false) exited

     [java] [Server@15ded0fd]: Startup sequence initiated from main() method
     [java] [Server@15ded0fd]: Loaded properties from [C:\Users\Ramesh\Desktop\Tutorials hibernate\Hibernate Code samples\jpwh-gettingstarted-070401\helloworld-native\server.properties]
     [java] [Server@15ded0fd]: Initiating startup sequence...
     [java] [Server@15ded0fd]: Server socket opened successfully in 29 ms.
     [java] [Server@15ded0fd]: Database [index=0, id=0, db=file:database/db, alias=] opened sucessfully in 469 ms.
     [java] [Server@15ded0fd]: Startup sequence completed in 523 ms.
     [java] [Server@15ded0fd]: 2010-11-08 22:11:08.027 HSQLDB server 1.8.0 is online
     [java] [Server@15ded0fd]: To close normally, connect and execute SHUTDOWN SQL
     [java] [Server@15ded0fd]: From command line, use [Ctrl]+[C] to abort abruptly
$ ant startdb 
Buildfile: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml

startdb:
     [java] [Server@a97b0b]: [Thread[main,5,main]]: checkRunning(false) entered
     [java] [Server@a97b0b]: [Thread[main,5,main]]: checkRunning(false) exited
     [java] [Server@a97b0b]: Startup sequence initiated from main() method
     [java] [Server@a97b0b]: Loaded properties from [/home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/server.properties]
     [java] [Server@a97b0b]: Initiating startup sequence...
     [java] [Server@a97b0b]: Server socket opened successfully in 39 ms.
     [java] [Server@a97b0b]: Database [index=0, id=0, db=file:database/db, alias=] opened sucessfully in 1148 ms.
     [java] [Server@a97b0b]: Startup sequence completed in 1281 ms.
     [java] [Server@a97b0b]: 2010-11-08 18:29:20.094 HSQLDB server 1.8.0 is online
     [java] [Server@a97b0b]: To close normally, connect and execute SHUTDOWN SQL
     [java] [Server@a97b0b]: From command line, use [Ctrl]+[C] to abort abruptly
$ ant schemaexport 
Buildfile: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml

compile:
    [mkdir] Created dir: /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build
    [javac] /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build.xml:39: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 3 source files to /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build

copymetafiles:
     [copy] Copying 3 files to /home/pascal/Projects/jpwh-gettingstarted-070401/helloworld-native/build

schemaexport:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 
[hibernatetool]     alter table MESSAGES 
[hibernatetool]         drop constraint FK_NEXT_MESSAGE;
[hibernatetool] 
[hibernatetool]     drop table MESSAGES if exists;
[hibernatetool] 
[hibernatetool]     create table MESSAGES (
[hibernatetool]         MESSAGE_ID bigint generated by default as identity (start with 1),
[hibernatetool]         MESSAGE_TEXT varchar(255),
[hibernatetool]         NEXT_MESSAGE_ID bigint,
[hibernatetool]         primary key (MESSAGE_ID)
[hibernatetool]     );
[hibernatetool] 
[hibernatetool]     alter table MESSAGES 
[hibernatetool]         add constraint FK_NEXT_MESSAGE 
[hibernatetool]         foreign key (NEXT_MESSAGE_ID) 
[hibernatetool]         references MESSAGES;
[hibernatetool] 1 errors occurred while performing <hbm2ddl>.
[hibernatetool] Error #1: java.sql.SQLException: Table not found: MESSAGES in statement [alter table MESSAGES]

BUILD SUCCESSFUL
Total time: 14 seconds
$ java -cp lib/hsqldb.jar org.hsqldb.Server