title: Connections could not be acquired from th e underlying database! -- HSQL DB
body: <p>I am trying to learn Hibernate from Java Persistence with hibernate by Gavin King.</p>
  
  <p>I just downloaded the examples given in the book from this location <a href="http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip" rel="nofollow">http://downloads.jboss.org/hibernate/caveatemptor/jpwh-gettingstarted-070401.zip</a></p>
  
  <p>I started my HSQL db using ant startdb and database started successfully.</p>
  
  <p>When trying to run the target schemaexport I am getting the below error..</p>
  
  <blockquote>
    <p>schemaexport: [hibernatetool]
    Executing Hibernate Tool with a
    Standard Configuration [hibernatetool]
    1. task: hbm2ddl (Generates database schema) [hibernatetool] 18:07:56,555 
    INFO Environment:500 - Hibernate
    3.2.0.cr5 [hibernatetool] 18:07:56,555  INFO Environment:533 -
    hibernate.properties not fo und
    [hibernatetool] 18:07:56,555  INFO
    Environment:667 - Bytecode provider
    name : cg lib [hibernatetool]
    18:07:56,571  INFO Environment:584 -
    using JDK 1.4 java.sql.Time stamp
    handling [hibernatetool] 18:07:56,617 
    INFO Configuration:1384 - configuring
    from file: h ibernate.cfg.xml
    [hibernatetool] 18:07:56,680  INFO
    Configuration:507 - Reading mappings
    from res ource: hello/Message.hbm.xml
    [hibernatetool] 18:07:56,758  INFO
    HbmBinder:300 - Mapping class:
    hello.Message
    -> MESSAGES [hibernatetool] 18:07:56,851  INFO Configuration:1465
    - Configured SessionFactor y: null [hibernatetool] 18:07:56,851  INFO
    Dialect:141 - Using dialect:
    org.hibernate.di alect.HSQLDialect
    [hibernatetool] 18:07:56,914  INFO
    SchemaExport:154 - Running hbm2ddl
    schema exp ort [hibernatetool]
    18:07:56,914  INFO SchemaExport:174 -
    writing generated schema t o file:
    C:\Users\Ramesh\Desktop\Tutorials\hibernate\Hibernate
    Code samples\jpwh-
    gettingstarted-070401\helloworld-native\helloworld-ddl.sql
    [hibernatetool] 18:07:56,914  INFO
    SchemaExport:179 - exporting generated
    schema  to database [hibernatetool]
    18:07:56,914  INFO
    C3P0ConnectionProvider:50 - C3P0 using
    driver : org.hsqldb.jdbcDriver at URL:
    jdbc:hsqldb:hsql://localhost
    [hibernatetool] 18:07:56,914  INFO
    C3P0ConnectionProvider:51 - Connection
    proper ties: {user=sa} [hibernatetool]
    18:07:56,914  INFO
    C3P0ConnectionProvider:54 - autocommit
    mode: false [hibernatetool]
    18:08:26,554  WARN
    BasicResourcePool:1222 -
    com.mchange.v2.resou
    rcepool.BasicResourcePool$AcquireTask@61f1680f
    -- Acquisition Attempt Failed!!! Clearing pending acquires. While
    trying to acquire a needed new
    resource, we fai led to succeed more
    than the maximum number of allowed
    acquisition attempts (30) .
    [hibernatetool] 18:08:26,554 ERROR
    SchemaExport:202 - schema export
    unsuccessful</p>
    
    <p>[hibernatetool] java.sql.SQLException:
    Connections could not be acquired from
    th e underlying database!
    [hibernatetool]         at
    com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.j
    ava:104) [hibernatetool]         at
    com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che
    ckoutPooledConnection(C3P0PooledConnectionPool.java:236)
    [hibernatetool]         at
    com.mchange.v2.c3p0.PoolBackedDataSource.getConnectio
    n(PoolBackedDataSource.java:94)
    [hibernatetool]         at
    org.hibernate.connection.C3P0ConnectionProvider.getCo
    nnection(C3P0ConnectionProvider.java:35)
    [hibernatetool]         at
    org.hibernate.tool.hbm2ddl.ManagedProviderConnectionH
    elper.prepare(ManagedProviderConnectionHelper.java:28)
    [hibernatetool]         at
    org.hibernate.tool.hbm2ddl.SchemaExport.execute(Schem
    aExport.java:180) [hibernatetool]<br>
    at
    org.hibernate.tool.hbm2ddl.SchemaExport.create(Schema
    Export.java:133) [hibernatetool]<br>
    at
    org.hibernate.tool.ant.Hbm2DDLExporterTask.execute(Hb
    m2DDLExporterTask.java:55)
    [hibernatetool]         at
    org.hibernate.tool.ant.HibernateToolTask.execute(Hibe
    rnateToolTask.java:171)
    [hibernatetool]         at
    org.apache.tools.ant.UnknownElement.execute(UnknownEl
    ement.java:291) [hibernatetool]<br>
    at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native
    M ethod) [hibernatetool]         at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
    hodAccessorImpl.java:39)
    [hibernatetool]         at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
    atingMethodAccessorImpl.java:25)
    [hibernatetool]         at
    java.lang.reflect.Method.invoke(Method.java:597)
    [hibernatetool]         at
    org.apache.tools.ant.dispatch.DispatchUtils.execute(D
    ispatchUtils.java:106) [hibernatetool]
    at
    org.apache.tools.ant.Task.perform(Task.java:348)
    [hibernatetool]         at
    org.apache.tools.ant.Target.execute(Target.java:390)
    [hibernatetool]         at
    org.apache.tools.ant.Target.performTasks(Target.java:
    411) [hibernatetool]         at
    org.apache.tools.ant.Project.executeSortedTargets(Pro
    ject.java:1397) [hibernatetool]<br>
    at
    org.apache.tools.ant.Project.executeTarget(Project.ja
    va:1366) [hibernatetool]         at
    org.apache.tools.ant.helper.DefaultExecutor.executeTa
    rgets(DefaultExecutor.java:41)
    [hibernatetool]         at
    org.apache.tools.ant.Project.executeTargets(Project.j
    ava:1249) [hibernatetool]         at
    org.apache.tools.ant.Main.runBuild(Main.java:801)
    [hibernatetool]         at
    org.apache.tools.ant.Main.startAnt(Main.java:218)
    [hibernatetool]         at
    org.apache.tools.ant.launch.Launcher.run(Launcher.jav
    a:280) [hibernatetool]         at
    org.apache.tools.ant.launch.Launcher.main(Launcher.ja
    va:109) [hibernatetool] Caused by:
    com.mchange.v2.resourcepool.CannotAcquireResourceExce
    ption: A ResourcePool could not
    acquire a resource from its primary
    factory or s ource. [hibernatetool]<br>
    at
    com.mchange.v2.resourcepool.BasicResourcePool.awaitAc
    quire(BasicResourcePool.java:970)
    [hibernatetool]         at
    com.mchange.v2.resourcepool.BasicResourcePool.checkou
    tResource(BasicResourcePool.java:208)
    [hibernatetool]         at
    com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.che
    ckoutPooledConnection(C3P0PooledConnectionPool.java:232)
    [hibernatetool]         ... 24 more
    [hibernatetool] 1 errors occurred
    while performing .
    [hibernatetool] Error #1:
    java.sql.SQLException: Connections
    could not be acquir ed from the
    underlying database! [hibernatetool]
    18:08:26,569  WARN
    BasicResourcePool:1222 -
    com.mchange.v2.resou
    rcepool.BasicResourcePool$AcquireTask@72f864fe
    -- Acquisition Attempt Failed!!! Clearing pending acquires. While
    trying to acquire a needed new
    resource, we fai led to succeed more
    than the maximum number of allowed
    acquisition attempts (30) .`</p>
  </blockquote>
  
  <p>I don't have too much knowledge about either hiberate or HSQL..</p>
  
  <p>Some one please explain whats wrong here??</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT:</strong> I am trying to run the project <code>helloworld-native</code>.</p>
  
  <p>The target given in the ant build.xml for startdb is as below:</p>
  
  <pre><code>&lt;!-- Start the HSQL DB server --&gt;
  &lt;target name="startdb" description="Run HSQL database server with clean DB"&gt;
      &lt;!-- Delete database files --&gt;
      &lt;delete dir="${database.dir}"/&gt;
      &lt;java classname="org.hsqldb.Server"
            fork="yes"
            classpathref="project.classpath"
            failonerror="true"&gt;
          &lt;arg value="-database.0"/&gt;
          &lt;arg value="file:${database.dir}/db"/&gt;
      &lt;/java&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>and when i run the command <code>ant startdb</code> i see the below output:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Then, i think i am running HSQL DB in server mode only (from the above output)..</p>
  
  <p>Please tell me what else I am missing..</p>